cvs: php4(PHP_4_3) /main main.c
| From: | Sascha Schumann | Date: | Tue, 13 May 2003 02:25:29 +0000 |
| Subject: | cvs: php4(PHP_4_3) /main main.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-20852@lists.php.net to get a copy of this message | ||
sas Mon May 12 22:25:29 2003 EDT
Modified files: (Branch: PHP_4_3)
/php4/main main.c
Log:
Ensure that we don't close a random fd
fchdir(0) Err#20 ENOTDIR
close(0) = 0
Index: php4/main/main.c
diff -u php4/main/main.c:1.512.2.28 php4/main/main.c:1.512.2.29
--- php4/main/main.c:1.512.2.28 Wed May 7 21:23:35 2003
+++ php4/main/main.c Mon May 12 22:25:29 2003
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: main.c,v 1.512.2.28 2003/05/08 01:23:35 iliaa Exp $ */
+/* $Id: main.c,v 1.512.2.29 2003/05/13 02:25:29 sas Exp $ */
/* {{{ includes
*/
@@ -1564,7 +1564,7 @@
zend_file_handle *prepend_file_p, *append_file_p;
zend_file_handle prepend_file, append_file;
#if HAVE_BROKEN_GETCWD
- int old_cwd_fd;
+ int old_cwd_fd = -1;
#else
char *old_cwd;
#endif
@@ -1648,8 +1648,10 @@
} zend_end_try();
#if HAVE_BROKEN_GETCWD
- fchdir(old_cwd_fd);
- close(old_cwd_fd);
+ if (old_cwd_fd != -1) {
+ fchdir(old_cwd_fd);
+ close(old_cwd_fd);
+ }
#else
if (old_cwd[0] != '\0') {
VCWD_CHDIR(old_cwd);