]> granicus.if.org Git - php/commitdiff
dup fds before fdopen'ing them, so that people cannot deliberately
authorSascha Schumann <sas@php.net>
Fri, 22 Jun 2001 07:07:48 +0000 (07:07 +0000)
committerSascha Schumann <sas@php.net>
Fri, 22 Jun 2001 07:07:48 +0000 (07:07 +0000)
close stdio streams.

This needs to be tested on non-UNIX platforms.

PR: #11599, #8624

ext/standard/php_fopen_wrapper.c

index 6e48f2b4aad7cbd8066be920447b55f77aeb17dc..9a0e261ecc99265a61d4530d1065dd1afc00de10 100644 (file)
@@ -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;