public inbox for dash@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] expand: Check d_type in expmeta before recursing
@ 2024-06-02  1:34 Herbert Xu
  2024-06-04 21:28 ` Jilles Tjoelker
  0 siblings, 1 reply; 3+ messages in thread
From: Herbert Xu @ 2024-06-02  1:34 UTC (permalink / raw)
  To: DASH Mailing List

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(+)

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) {
-- 
2.39.2

-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] expand: Check d_type in expmeta before recursing
  2024-06-02  1:34 [PATCH] expand: Check d_type in expmeta before recursing Herbert Xu
@ 2024-06-04 21:28 ` Jilles Tjoelker
  2024-06-08  3:42   ` [v2 PATCH] " Herbert Xu
  0 siblings, 1 reply; 3+ messages in thread
From: Jilles Tjoelker @ 2024-06-04 21:28 UTC (permalink / raw)
  To: Herbert Xu; +Cc: DASH Mailing List

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.

-- 
Jilles Tjoelker

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [v2 PATCH] expand: Check d_type in expmeta before recursing
  2024-06-04 21:28 ` Jilles Tjoelker
@ 2024-06-08  3:42   ` Herbert Xu
  0 siblings, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2024-06-08  3:42 UTC (permalink / raw)
  To: Jilles Tjoelker; +Cc: DASH Mailing List

On Tue, Jun 04, 2024 at 11:28:35PM +0200, Jilles Tjoelker wrote:
>
> Good idea, but DT_UNKNOWN might 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 <herbert@gondor.apana.org.au>
---
 src/expand.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/expand.c b/src/expand.c
index 345c498..6912e39 100644
--- a/src/expand.c
+++ b/src/expand.c
@@ -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) {
-- 
2.39.2

-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-06-08  3:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-02  1:34 [PATCH] expand: Check d_type in expmeta before recursing Herbert Xu
2024-06-04 21:28 ` Jilles Tjoelker
2024-06-08  3:42   ` [v2 PATCH] " Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox