diff options
| author | Sascha Schumann <sas@php.net> | 2003-05-13 23:51:57 +0000 |
|---|---|---|
| committer | Sascha Schumann <sas@php.net> | 2003-05-13 23:51:57 +0000 |
| commit | 0e47b9242de85736e7cc5f94d10b9b38b01b6707 (patch) | |
| tree | 074b8e92ccb9fd2802a687781a5e7cb8960bf0f7 /ext/standard/php_fopen_wrapper.c | |
| parent | 4066bd0a1787fb06e81b6c3202dd120b37dcf063 (diff) | |
| download | php-git-0e47b9242de85736e7cc5f94d10b9b38b01b6707.tar.gz | |
Readd fd 0-2 protection, so that users cannot close them
Diffstat (limited to 'ext/standard/php_fopen_wrapper.c')
| -rw-r--r-- | ext/standard/php_fopen_wrapper.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/ext/standard/php_fopen_wrapper.c b/ext/standard/php_fopen_wrapper.c index 87457e60e5..1d1810b49f 100644 --- a/ext/standard/php_fopen_wrapper.c +++ b/ext/standard/php_fopen_wrapper.c @@ -124,6 +124,7 @@ php_stream_ops php_stream_input_ops = { php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC) { int fd = -1; + php_stream *stream = NULL; if (!strncasecmp(path, "php://", 6)) path += 6; @@ -145,9 +146,13 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, char *path, ch } if (fd != -1) { - return php_stream_fopen_from_fd(fd, mode, NULL); + int nfd = dup(fd); + + stream = php_stream_fopen_from_fd(nfd, mode, NULL); + + if (!stream) close(nfd); } - return NULL; + return stream; } static php_stream_wrapper_ops php_stdio_wops = { |
