diff options
author | Sascha Schumann <sas@php.net> | 2001-06-22 07:07:48 +0000 |
---|---|---|
committer | Sascha Schumann <sas@php.net> | 2001-06-22 07:07:48 +0000 |
commit | 6558ae6f21e466bf2b38ab39bfbdf47ec8349225 (patch) | |
tree | e27554c0a8c4c3ef478e7dc56dcb5b51217f3b2a /ext/standard/php_fopen_wrapper.c | |
parent | 5bf89ce61c4e5948cde1b6d4eaec4d3ae4317596 (diff) | |
download | php-git-6558ae6f21e466bf2b38ab39bfbdf47ec8349225.tar.gz |
dup fds before fdopen'ing them, so that people cannot deliberately
close stdio streams.
This needs to be tested on non-UNIX platforms.
PR: #11599, #8624
Diffstat (limited to 'ext/standard/php_fopen_wrapper.c')
-rw-r--r-- | ext/standard/php_fopen_wrapper.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/ext/standard/php_fopen_wrapper.c b/ext/standard/php_fopen_wrapper.c index 6e48f2b4aa..9a0e261ecc 100644 --- a/ext/standard/php_fopen_wrapper.c +++ b/ext/standard/php_fopen_wrapper.c @@ -21,6 +21,7 @@ #include <stdio.h> #include <stdlib.h> +#include <unistd.h> #include "php.h" #include "php_globals.h" @@ -37,11 +38,11 @@ FILE *php_fopen_url_wrap_php(char *path, char *mode, int options, int *issock, i *issock = 0; if (!strcasecmp(res, "stdin")) { - return fdopen(STDIN_FILENO, mode); + return fdopen(dup(STDIN_FILENO), mode); } else if (!strcasecmp(res, "stdout")) { - return fdopen(STDOUT_FILENO, mode); + return fdopen(dup(STDOUT_FILENO), mode); } else if (!strcasecmp(res, "stderr")) { - return fdopen(STDERR_FILENO, mode); + return fdopen(dup(STDERR_FILENO), mode); } return NULL; |