Subject: bin/5001: sh doesn't like "cd ./"
To: None <gnats-bugs@gnats.netbsd.org>
From: Tom Yu <tlyu@mit.edu>
List: netbsd-bugs
Date: 02/16/1998 15:56:56
>Number: 5001
>Category: bin
>Synopsis: sh doesn't like "cd ./"
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Feb 16 13:05:01 1998
>Last-Modified:
>Originator: Tom Yu
>Organization:
dis
>Release: 971126 or so
>Environment:
System: NetBSD chaos-in-motion 1.3_ALPHA NetBSD 1.3_ALPHA (CHAOS) #16: Wed Nov 26 17:37:10 EST 1997 tlyu@chaos-in-motion:/usr/src/sys/arch/i386/compile/CHAOS i386
>Description:
There is a bug in bin/sh/cd.c that prevents the command "cd ./"
from working. This is due to the special handling of a leading "./" in
the destination directory in cdcmd().
>How-To-Repeat:
/bin/sh
cd ./
>Fix:
One fix is to check to make sure that the path is longer
than two bytes before lopping off the leading "./". This is against
/* $NetBSD: cd.c,v 1.23 1997/07/04 20:59:40 christos Exp $ */,
which is still current, I believe.
--- /usr/stock-current/src/bin/sh/cd.c Sat Jul 5 07:12:27 1997
+++ cd.c Mon Feb 16 15:45:55 1998
@@ -110,7 +110,8 @@
/*
* XXX - rethink
*/
- if (p[0] == '.' && p[1] == '/')
+ if (p[0] == '.' && p[1] == '/' &&
+ strlen(p) > 2)
p += 2;
print = strcmp(p, dest);
}
>Audit-Trail:
>Unformatted: