From per@hedeland.org  Sat Aug  7 21:26:33 2004
Return-Path: <per@hedeland.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 5FD4916A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Sat,  7 Aug 2004 21:26:33 +0000 (GMT)
Received: from pluto.hedeland.org (1-1-1-13a.mal.sth.bostream.se [82.182.84.27])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 50BC443D1D
	for <FreeBSD-gnats-submit@freebsd.org>; Sat,  7 Aug 2004 21:26:32 +0000 (GMT)
	(envelope-from per@hedeland.org)
Received: from pluto.hedeland.org (localhost [127.0.0.1])
	by pluto.hedeland.org (8.13.0/8.13.0) with ESMTP id i77LQUQa078016
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO)
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 7 Aug 2004 23:26:30 +0200 (CEST)
Received: (from per@localhost)
	by pluto.hedeland.org (8.13.0/8.13.0/Submit) id i77LQU3I078015;
	Sat, 7 Aug 2004 23:26:30 +0200 (CEST)
Message-Id: <200408072126.i77LQU3I078015@pluto.hedeland.org>
Date: Sat, 7 Aug 2004 23:26:30 +0200 (CEST)
From: Per Hedeland <per@hedeland.org>
Reply-To: Per Hedeland <per@hedeland.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] Globbing bug in /bin/sh
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         70147
>Category:       bin
>Synopsis:       [PATCH] Globbing bug in /bin/sh
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Aug 07 21:30:20 GMT 2004
>Closed-Date:    Tue Sep 06 17:23:47 GMT 2005
>Last-Modified:  Tue Sep 06 17:23:47 GMT 2005
>Originator:     Per Hedeland
>Release:        FreeBSD 5.2-RELEASE i386
>Organization:
>Environment:
System: FreeBSD pluto.hedeland.org 5.2-RELEASE FreeBSD 5.2-RELEASE #1: Sun Jan 18 13:02:43 CET 2004 per@pluto.hedeland.org:/usr/src/sys/i386/compile/PLUTO i386


>Description:
	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.

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

>Fix:

--- /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')
 				break;
 		}
-		if (metaflag == 0 || stat(expdir, &statb) >= 0)
+		if (metaflag == 0 || lstat(expdir, &statb) >= 0)
 			addfname(expdir);
 		return;
 	}



>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: stefanf 
State-Changed-When: Tue Sep 6 17:22:59 GMT 2005 
State-Changed-Why:  
Fixed two months ago.  Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=70147 
>Unformatted:
