Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug where we would overwrite existing file descriptors with dup2().
Now we check file descriptors (even those above #10) before using them. This is a recurrence of the bug described here: http://www.oilshell.org/blog/2017/07/02.html If you do 'import random' in Python, it results in /dev/urandom being permanently open (which can be seen in the blog post!) At the time, I incorrectly fixed the bug by just opening our own descriptors above #10. But it's possible that CPython will subsequently open something above #10 (/dev/urandom appeared as #12), so we have to additionally check descriptors before we use them. NOTE: 'import cgi' eventually causes 'import random'. We're only using it for cgi.escape(), but cgi.FieldStorage() uses tempfile, which uses a random number generator. Also: minimize the test case as gold/configure-bug.sh. 'test/gold.sh configure' was the case that caught this bug. The spec tests didn't find it! Because it appears to take about 4 redirects for this to happen!
- Loading branch information
Andy Chu
committed
Sep 4, 2018
1 parent
41c2121
commit 94c7d78
Showing
3 changed files
with
36 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
detect_readline() { | ||
echo foo >/dev/null 2>&1 | ||
echo "two" 1>&2 | ||
} | ||
|
||
main() { | ||
detect_readline > _tmp/f2-out.txt | ||
#detect_readline | ||
} | ||
|
||
main "$@" |
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