[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
cd builtin fails to resolve paths PATH_MAX in length
From: |
Karen Crippes |
Subject: |
cd builtin fails to resolve paths PATH_MAX in length |
Date: |
Wed, 28 Apr 2004 11:48:53 -0700 |
From: karen@apple.com
To: bug-bash@gnu.org
Subject: cd builtin fails to resolve paths PATH_MAX in length
Configuration Information [Automatically generated, do not change]:
Machine: powerpc
OS: darwin8.0
Compiler: gcc
Compilation CFLAGS: -arch i386 -arch ppc -g -Os -pipe -no-cpp-precomp
-arch i386 -arch ppc -pipe -DPROGRAM='bash' -DCONF_HOSTTYPE='powe\
rpc' -DCONF_OSTYPE='darwin8.0'
-DCONF_MACHTYPE='powerpc-apple-darwin8.0' -DCONF_VENDOR='apple' -DSHELL
-DHAVE_CONFIG_H -DMACOSX -I. -\
I/SourceCache/bash/bash-30/bash
-I/SourceCache/bash/bash-30/bash/include
-I/SourceCache/bash/bash-30/bash/lib -arch i386 -arch ppc -g -O\
s -pipe -no-cpp-precomp -arch i386 -arch ppc -pipe
uname output: Darwin watusi5.apple.com 8.0.0 Darwin Kernel Version
8.0.0: Mon Mar 8 16:08:50 PST 2004; root:xnu.roots/xnu~obj/RELEASE_P\
PC Power Macintosh powerpc
Machine Type: powerpc-apple-darwin8.0
Bash Version: 2.05b
Patch Level: 0
Release Status: release
Description:
We have a large number of UNIX conformance tests failing. Specifically
they fail when the cd builtin command is given a directory whose
pathname length is (PATH_MAX - 1).
The failures only occur when invoking bash as /bin/sh.
The PATH_MAX limit includes the trailing null byte. So, the conformance
test successfully creates multiple directories such that the relative
path
to the final directory is 1023 chars long, leaving room for that null
byte.
Then the test tries to 'cd' to that long path and fails, even though
the directory path exists. The long, 1023 char, path passed to cd
is not absolute. It looks like the cd builtin translates the directory
from a relative
path to an absoulte path which can force the resolved path to exceed
PATH_MAX.
builtins/cd.def calls sh_canonpath() with an absolute pathname.
In sh_canonpath() a stat() fails because this new, absolute path
exceeds PATH_MAX.
Ignoring this failure (my hack to make progress) is not the correct and
simple fix --
though it allows the change directory to proceed.
Changing the shell's idea of the current working directory when
PATH_MAX has
been exceeded, spews long stderr messages, as do other paths through
get_working_directory() in common.c. So, a clean fix is less trivial.
The standard states:
When 'directory' is a pathname which is a string of no more than
PATH_MAX bytes then 'directory' can be resolved.
Repeat-By: (note the path should be 1023 chars long)
> /bin/sh
> cd /tmp
> mkdir -p
cdtestsh_dir/cdtestsh_subdir/
0xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxx\
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\
xxxxxxxxxxxxx/
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/xxxxxxxxxxxx\
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/xxxxxxxxxxxxxx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xxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxx/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: No such file or directory
> echo $?
1
When cd is involked in the /bin/bash environment, it produces output
that makes it appear to have failed when in fact, it did not.
The return code indicates success. I think in this case, the output is
caused when the notion of PWD is being updated.
Behavior beyond this point is misleading.
-------------------------------
Karen Crippes
CoreOS/BSD Engineer
Apple Computer Inc.
2 Infinite Loop
Cupertino, CA 95014
direct: 408-862-7412
-------------------------------
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- cd builtin fails to resolve paths PATH_MAX in length,
Karen Crippes <=