This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][BZ #10246] glob() with GLOB_NOCHECK is returning a modified pattern sometimes.


This bug was caused joining cases when we do not check for errors or
directory exists. A fix is simple, jump to code that handles no matches.

	[BZ #10246]
	* posix/glob.c (glob): Return correct value when GLOB_NOCHECK
	is specified.

diff --git a/posix/glob.c b/posix/glob.c
index 85237c2..1384bcc 100644
--- a/posix/glob.c
+++ b/posix/glob.c
@@ -958,8 +958,7 @@ glob (pattern, flags, errfunc, pglob)
       struct_stat64 st64;
       /* Return the directory if we don't check for error or if it exists.  */
-      if ((flags & GLOB_NOCHECK)
-	  || (((__builtin_expect (flags & GLOB_ALTDIRFUNC, 0))
+      if ((((__builtin_expect (flags & GLOB_ALTDIRFUNC, 0))
 	       ? ((*pglob->gl_stat) (dirname, &st) == 0
 		  && S_ISDIR (st.st_mode))
 	       : (__stat64 (dirname, &st64) == 0 && S_ISDIR (st64.st_mode)))))
@@ -1006,6 +1005,8 @@ glob (pattern, flags, errfunc, pglob)
 	  return 0;
+      else if (flags & GLOB_NOCHECK)
+	goto no_matches;
       /* Not found.  */
       return GLOB_NOMATCH;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]