bin/70147: [PATCH] Globbing bug in /bin/sh

Per Hedeland per at
Sat Aug 7 14:30:21 PDT 2004

>Number:         70147
>Category:       bin
>Synopsis:       [PATCH] Globbing bug in /bin/sh
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Aug 07 21:30:20 GMT 2004
>Originator:     Per Hedeland
>Release:        FreeBSD 5.2-RELEASE i386
System: FreeBSD 5.2-RELEASE FreeBSD 5.2-RELEASE #1: Sun Jan 18 13:02:43 CET 2004 per at i386

	Globbing in /bin/sh fails to match a dangling symlink. I don't
        know if there is a spec that says that the match should succeed,
        but this behaviour differs from at least FreeBSD /bin/[t]csh,
        bash 2.05b (invoked as 'bash' or 'sh'), Solaris 8 /bin/sh and
        ditto /bin/ksh, and definitely violates the principle of least
        surprise - i.e. there's no doubt that it should be considered a
        bug in my opinion.

	$ mkdir /tmp/foo
	$ ln -s baz /tmp/foo/bar
	$ ls -l /tmp/*/bar
	ls: /tmp/*/bar: No such file or directory


--- /usr/src/bin/sh/expand.c.ORIG	Sun Aug  3 06:28:10 2003
+++ /usr/src/bin/sh/expand.c	Sat Aug  7 23:14:13 2004
@@ -1166,7 +1166,7 @@
 			if (*p == '\0')
-		if (metaflag == 0 || stat(expdir, &statb) >= 0)
+		if (metaflag == 0 || lstat(expdir, &statb) >= 0)


More information about the freebsd-bugs mailing list