]> git.ipfire.org Git - thirdparty/make.git/commitdiff
* lib/glob.c (glob_in_dir): [SV 53465] Allow symlinks to directories.
authorPaul Smith <psmith@gnu.org>
Sat, 4 Aug 2018 18:04:44 +0000 (14:04 -0400)
committerPaul Smith <psmith@gnu.org>
Sat, 4 Aug 2018 18:26:10 +0000 (14:26 -0400)
Fix from Rich Felker <bugdal@aerifal.cx> on the musl mailing list.
* tests/scripts/functions/wildcard: Create a regression test for this.

lib/glob.c
tests/scripts/functions/wildcard

index df2b23e6164dcb155a12083deac09e07d1515043..f221a5317183951c97a395fcfd078d3c19e3f8e3 100644 (file)
@@ -1335,7 +1335,7 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
                  /* If we shall match only directories use the information
                     provided by the dirent call if possible.  */
                  if ((flags & GLOB_ONLYDIR)
-                     && d->d_type != DT_UNKNOWN && d->d_type != DT_DIR)
+                     && d->d_type != DT_UNKNOWN && d->d_type != DT_DIR && d->d_type != DT_LNK)
                    continue;
 #endif
 
index f91d9adb8c948d6cc77bda8bdc7c7960679c2f7e..ad96473de36de261825a5cdb8d1d22777bcc0f3b 100644 (file)
@@ -100,4 +100,19 @@ unlink('xxx.yyy');
 run_make_test(q!exists: ; @echo file=$(wildcard xxx.yyy)!,
               '', "file=\n");
 
+# TEST #6: check for wildcards matching directories
+# See SV 53465
+
+if ($port_type ne 'W32' && eval { symlink("",""); 1 }) {
+    my $dir = '__rdir';
+    my $lnk = '__ldir';
+    mkdir($dir, 0777);
+    symlink($dir, $lnk);
+
+    run_make_test(qq!all: ; \@echo \$(wildcard $lnk*/.)!, '', "$lnk/.");
+
+    unlink($lnk);
+    rmdir($dir);
+}
+
 1;