Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Fix crash on cd in subshell with PWD unset (re: 5ee290c)
Reproducer: $ ksh -c 'unset PWD; (cd /); :' Memory fault The shell crashes because b_cd() is testing the value of the PWD variable without checking if there is one. src/cmd/ksh93/sh/path.c: path_pwd(): - Never return an unfreeable pointer to e_dot; always return a freeable pointer. This fixes another corner-case crashing bug. - Make sure the PWD variable gets assigned a value if it doesn't have one, even if it's the "." fallback. However, if the PWD is inaccessible but we did inherit a $PWD value that starts with a /, then use the existing $PWD value as this will help the shell fail gracefully. src/cmd/ksh93/bltins/cd_pwd.c: - b_cd(): When checking if the PWD is valid, use the sh.pwd copy instead of the PWD variable. This fixes the crash above. - b_cd(): Since path_pwd() now always returns a freeable value, free sh.pwd unconditionally before setting the new value. - b_pwd(): Not only check that path_pwd() returns a value starting with a slash, but also verify it with test_inode() and error out if it's wrong. This makes the 'pwd' command useful for checking that the PWD is currently accessible. src/cmd/ksh93/data/msg.c: - Change e_pwd error message for accuracy and clarity.
- Loading branch information
Showing
6 changed files
with
46 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters