Message ID | ZlvMLrrmMR92Bbvq@gondor.apana.org.au (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Herbert Xu |
Headers | show |
Series | expand: Check d_type in expmeta before recursing | expand |
On Sun, Jun 02, 2024 at 09:34:38AM +0800, Herbert Xu wrote: > If the directory pointer is not a directory or symlink, do not > recurse into expmeta. > + if (c && dp->d_type != DT_DIR && dp->d_type != DT_LNK) > + goto check_int; Good idea, but DT_UNKNOWN might also be a directory or a symlink to one.
diff --git a/src/expand.c b/src/expand.c index 345c498..527ce7c 100644 --- a/src/expand.c +++ b/src/expand.c @@ -1722,6 +1722,8 @@ static char *expmeta(char *name, unsigned name_len, size_t expdir_len) if (*dname == '.' && !matchdot) goto check_int; + if (c && dp->d_type != DT_DIR && dp->d_type != DT_LNK) + goto check_int; len = strlen(dname) + 1; p = dname; if (!FNMATCH_IS_ENABLED) {
If the directory pointer is not a directory or symlink, do not recurse into expmeta. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> --- src/expand.c | 2 ++ 1 file changed, 2 insertions(+)