expand: Check d_type in expmeta before recursing
PATCH 1/1 expand: Check d_type in expmeta before recursing
If the directory pointer is not a directory or symlink, do not recurse into expmeta.
Signed-off-by Herbert Xu <[email protected]>
--- src/expand.c | 2 ++ 1 file changed, 2 insertions(+)
src/expand.c +2 -0
@@ -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 ) {
Signature · 6 lines
2.39.2 -- Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
src/expand.c static char *expmeta(char *name, unsigned name_len, size_t expdir_len) · line 1726
Quoted 5 lines · Herbert Xu
If the directory pointer is not a directory or symlink, do not recurse into expmeta.
src/expand.c +2
-0+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.
Signature · 1 line
Jilles Tjoelker
PATCH v2 1/1 expand: Check d_type in expmeta before recursing
Quoted 2 lines · Jilles Tjoelker
Good idea, but
DT_UNKNOWNmight also be a directory or a symlink to one.
Thanks for catching this!
---8<---
If the directory pointer is not a directory, a symlink or an unknown entity, do not recurse into expmeta.
Signed-off-by Herbert Xu <[email protected]>
--- src/expand.c | 3 +++ 1 file changed, 3 insertions(+)
src/expand.c +3 -0
@@ -1722,6 +1722,9 @@ 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 && + dp->d_type !=DT_UNKNOWN ) + goto check_int; len =strlen (dname) +1 ; p = dname;if (!FNMATCH_IS_ENABLED ) {
Signature · 6 lines
2.39.2 -- Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt