diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2005-10-03 01:03:46 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2005-10-03 01:03:46 (GMT) |
commit | c2b7c59267153c21a1d53fdba634430723328b74 (patch) | |
tree | 4178b2a9062148ded6b96519734e9ca3f2fe7bd9 /Python/sysmodule.c | |
parent | 3529f2126cbee49cae108d54ddf25db86feeee1d (diff) | |
download | cpython-c2b7c59267153c21a1d53fdba634430723328b74.zip cpython-c2b7c59267153c21a1d53fdba634430723328b74.tar.gz cpython-c2b7c59267153c21a1d53fdba634430723328b74.tar.bz2 |
Backport:
SF bug #887946, segfault if redirecting directory
Also provide a warning if a directory is passed on the command line.
Add minimal command line test.
Diffstat (limited to 'Python/sysmodule.c')
-rw-r--r-- | Python/sysmodule.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 5a8c7af..0775bb8 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -947,6 +947,15 @@ _PySys_Init(void) m = Py_InitModule3("sys", sys_methods, sys_doc); sysdict = PyModule_GetDict(m); + { + /* XXX: does this work on Win/Win64? (see posix_fstat) */ + struct stat sb; + if (fstat(fileno(stdin), &sb) == 0 && + S_ISDIR(sb.st_mode)) { + Py_FatalError("<stdin> is a directory"); + } + } + /* Closing the standard FILE* if sys.std* goes aways causes problems * for embedded Python usages. Closing them when somebody explicitly * invokes .close() might be possible, but the FAQ promises they get |