felipe          Tue Jul 22 14:11:26 2008 UTC

  Modified files:              (Branch: PHP_5_2)
    /php-src/ext/standard       file.c fsock.c proc_open.c streamsfuncs.c 
    /php-src/ext/standard/tests/file    fscanf_variation10.phpt 
                                        fscanf_variation16.phpt 
                                        fscanf_variation22.phpt 
                                        fscanf_variation29.phpt 
                                        fscanf_variation35.phpt 
                                        fscanf_variation4.phpt 
                                        fscanf_variation41.phpt 
                                        fscanf_variation47.phpt 
    /php-src/main       php_streams.h 
    /php-src/sapi/cli   php_cli.c 
  Log:
  - MFH: Fixed bug #44246 (closedir() accepts a file resource opened by fopen())
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.409.2.6.2.32&r2=1.409.2.6.2.33&diff_format=u
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.409.2.6.2.32 
php-src/ext/standard/file.c:1.409.2.6.2.33
--- php-src/ext/standard/file.c:1.409.2.6.2.32  Sun May  4 21:19:17 2008
+++ php-src/ext/standard/file.c Tue Jul 22 14:11:25 2008
@@ -21,7 +21,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: file.c,v 1.409.2.6.2.32 2008/05/04 21:19:17 colder Exp $ */
+/* $Id: file.c,v 1.409.2.6.2.33 2008/07/22 14:11:25 felipe Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -861,6 +861,8 @@
        stream = php_stream_fopen_tmpfile();
 
        if (stream) {
+               stream->flags |= PHP_STREAM_FLAG_FCLOSE;
+
                php_stream_to_zval(stream, return_value);
        } else {
                RETURN_FALSE;
@@ -891,6 +893,8 @@
        if (stream == NULL) {
                RETURN_FALSE;
        }
+       
+       stream->flags |= PHP_STREAM_FLAG_FCLOSE;
 
        php_stream_to_zval(stream, return_value);
 
@@ -912,6 +916,12 @@
        }
 
        PHP_STREAM_TO_ZVAL(stream, arg1);
+       
+       if (!(stream->flags & PHP_STREAM_FLAG_FCLOSE)) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "%d is not a valid 
stream resource", stream->rsrc_id);
+               RETURN_FALSE;
+       }
+       
        if (!stream->is_persistent) {
                zend_list_delete(stream->rsrc_id);
        } else {
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/fsock.c?r1=1.121.2.1.2.2&r2=1.121.2.1.2.3&diff_format=u
Index: php-src/ext/standard/fsock.c
diff -u php-src/ext/standard/fsock.c:1.121.2.1.2.2 
php-src/ext/standard/fsock.c:1.121.2.1.2.3
--- php-src/ext/standard/fsock.c:1.121.2.1.2.2  Mon Dec 31 07:20:12 2007
+++ php-src/ext/standard/fsock.c        Tue Jul 22 14:11:25 2008
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: fsock.c,v 1.121.2.1.2.2 2007/12/31 07:20:12 sebastian Exp $ */
+/* $Id: fsock.c,v 1.121.2.1.2.3 2008/07/22 14:11:25 felipe Exp $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -79,6 +79,8 @@
        stream = php_stream_xport_create(hostname, hostname_len, 
ENFORCE_SAFE_MODE | REPORT_ERRORS,
                        STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT, hashkey, 
&tv, NULL, &errstr, &err);
 
+       stream->flags |= PHP_STREAM_FLAG_FCLOSE;
+
        if (port > 0) {
                efree(hostname);
        }
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/proc_open.c?r1=1.36.2.1.2.19&r2=1.36.2.1.2.20&diff_format=u
Index: php-src/ext/standard/proc_open.c
diff -u php-src/ext/standard/proc_open.c:1.36.2.1.2.19 
php-src/ext/standard/proc_open.c:1.36.2.1.2.20
--- php-src/ext/standard/proc_open.c:1.36.2.1.2.19      Tue Apr  8 08:45:51 2008
+++ php-src/ext/standard/proc_open.c    Tue Jul 22 14:11:25 2008
@@ -15,7 +15,7 @@
    | Author: Wez Furlong <[EMAIL PROTECTED]>                           |
    +----------------------------------------------------------------------+
  */
-/* $Id: proc_open.c,v 1.36.2.1.2.19 2008/04/08 08:45:51 jani Exp $ */
+/* $Id: proc_open.c,v 1.36.2.1.2.20 2008/07/22 14:11:25 felipe Exp $ */
 
 #if 0 && (defined(__linux__) || defined(sun) || defined(__IRIX__))
 # define _BSD_SOURCE           /* linux wants this when XOPEN mode is on */
@@ -969,7 +969,7 @@
                                        zval *retfp;
 
                                        /* nasty hack; don't copy it */
-                                       stream->flags |= 
PHP_STREAM_FLAG_NO_SEEK;
+                                       stream->flags |= 
PHP_STREAM_FLAG_NO_SEEK | PHP_STREAM_FLAG_FCLOSE;
                                        
                                        MAKE_STD_ZVAL(retfp);
                                        php_stream_to_zval(stream, retfp);
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/streamsfuncs.c?r1=1.58.2.6.2.21&r2=1.58.2.6.2.22&diff_format=u
Index: php-src/ext/standard/streamsfuncs.c
diff -u php-src/ext/standard/streamsfuncs.c:1.58.2.6.2.21 
php-src/ext/standard/streamsfuncs.c:1.58.2.6.2.22
--- php-src/ext/standard/streamsfuncs.c:1.58.2.6.2.21   Wed May  7 20:02:42 2008
+++ php-src/ext/standard/streamsfuncs.c Tue Jul 22 14:11:25 2008
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: streamsfuncs.c,v 1.58.2.6.2.21 2008/05/07 20:02:42 bjori Exp $ */
+/* $Id: streamsfuncs.c,v 1.58.2.6.2.22 2008/07/22 14:11:25 felipe Exp $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -122,6 +122,7 @@
                        STREAM_XPORT_CLIENT | (flags & 
PHP_STREAM_CLIENT_CONNECT ? STREAM_XPORT_CONNECT : 0) |
                        (flags & PHP_STREAM_CLIENT_ASYNC_CONNECT ? 
STREAM_XPORT_CONNECT_ASYNC : 0),
                        hashkey, &tv, context, &errstr, &err);
+               
 
        if (stream == NULL) {
                /* host might contain binary characters */
@@ -150,6 +151,8 @@
                RETURN_FALSE;
        }
        
+       stream->flags |= PHP_STREAM_FLAG_FCLOSE;
+       
        if (errstr) {
                efree(errstr);
        }
@@ -195,6 +198,8 @@
        stream = php_stream_xport_create(host, host_len, ENFORCE_SAFE_MODE | 
REPORT_ERRORS,
                        STREAM_XPORT_SERVER | flags,
                        NULL, NULL, context, &errstr, &err);
+                       
+       stream->flags |= PHP_STREAM_FLAG_FCLOSE;
 
        if (stream == NULL) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to connect 
to %s (%s)", host, errstr == NULL ? "Unknown error" : errstr);
@@ -262,7 +267,9 @@
                                NULL, NULL,
                                &tv, &errstr
                                TSRMLS_CC) && clistream) {
-
+               
+               clistream->flags |= PHP_STREAM_FLAG_FCLOSE;
+               
                if (peername) {
                        Z_TYPE_P(peername) = IS_STRING;
                }
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/fscanf_variation10.phpt?r1=1.1.2.1&r2=1.1.2.2&diff_format=u
Index: php-src/ext/standard/tests/file/fscanf_variation10.phpt
diff -u php-src/ext/standard/tests/file/fscanf_variation10.phpt:1.1.2.1 
php-src/ext/standard/tests/file/fscanf_variation10.phpt:1.1.2.2
--- php-src/ext/standard/tests/file/fscanf_variation10.phpt:1.1.2.1     Fri Aug 
10 17:54:47 2007
+++ php-src/ext/standard/tests/file/fscanf_variation10.phpt     Tue Jul 22 
14:11:25 2008
@@ -68,7 +68,7 @@
 
 // closing the resources
 fclose($fp);
-fclose($dfp);
+closedir($dfp);
 
 echo "\n*** Done ***";
 ?>
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/fscanf_variation16.phpt?r1=1.1.2.1&r2=1.1.2.2&diff_format=u
Index: php-src/ext/standard/tests/file/fscanf_variation16.phpt
diff -u php-src/ext/standard/tests/file/fscanf_variation16.phpt:1.1.2.1 
php-src/ext/standard/tests/file/fscanf_variation16.phpt:1.1.2.2
--- php-src/ext/standard/tests/file/fscanf_variation16.phpt:1.1.2.1     Fri Aug 
10 17:54:48 2007
+++ php-src/ext/standard/tests/file/fscanf_variation16.phpt     Tue Jul 22 
14:11:25 2008
@@ -67,7 +67,7 @@
 
 // closing the resources
 fclose($fp);
-fclose($dfp);
+closedir($dfp);
 
 echo "\n*** Done ***";
 ?>
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/fscanf_variation22.phpt?r1=1.1.2.1&r2=1.1.2.2&diff_format=u
Index: php-src/ext/standard/tests/file/fscanf_variation22.phpt
diff -u php-src/ext/standard/tests/file/fscanf_variation22.phpt:1.1.2.1 
php-src/ext/standard/tests/file/fscanf_variation22.phpt:1.1.2.2
--- php-src/ext/standard/tests/file/fscanf_variation22.phpt:1.1.2.1     Fri Aug 
10 17:54:47 2007
+++ php-src/ext/standard/tests/file/fscanf_variation22.phpt     Tue Jul 22 
14:11:25 2008
@@ -67,7 +67,7 @@
 
 // closing the resources
 fclose($fp);
-fclose($dfp);
+closedir($dfp);
 
 echo "\n*** Done ***";
 ?>
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/fscanf_variation29.phpt?r1=1.1.2.1&r2=1.1.2.2&diff_format=u
Index: php-src/ext/standard/tests/file/fscanf_variation29.phpt
diff -u php-src/ext/standard/tests/file/fscanf_variation29.phpt:1.1.2.1 
php-src/ext/standard/tests/file/fscanf_variation29.phpt:1.1.2.2
--- php-src/ext/standard/tests/file/fscanf_variation29.phpt:1.1.2.1     Fri Aug 
10 17:54:47 2007
+++ php-src/ext/standard/tests/file/fscanf_variation29.phpt     Tue Jul 22 
14:11:25 2008
@@ -68,7 +68,7 @@
 
 // closing the resources
 fclose($fp);
-fclose($dfp);
+closedir($dfp);
 
 echo "\n*** Done ***";
 ?>
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/fscanf_variation35.phpt?r1=1.1.2.1&r2=1.1.2.2&diff_format=u
Index: php-src/ext/standard/tests/file/fscanf_variation35.phpt
diff -u php-src/ext/standard/tests/file/fscanf_variation35.phpt:1.1.2.1 
php-src/ext/standard/tests/file/fscanf_variation35.phpt:1.1.2.2
--- php-src/ext/standard/tests/file/fscanf_variation35.phpt:1.1.2.1     Fri Aug 
10 17:54:48 2007
+++ php-src/ext/standard/tests/file/fscanf_variation35.phpt     Tue Jul 22 
14:11:25 2008
@@ -63,7 +63,7 @@
 
 // closing the resources
 fclose($fp);
-fclose($dfp);
+closedir($dfp);
 
 echo "\n*** Done ***";
 ?>
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/fscanf_variation4.phpt?r1=1.1.2.1&r2=1.1.2.2&diff_format=u
Index: php-src/ext/standard/tests/file/fscanf_variation4.phpt
diff -u php-src/ext/standard/tests/file/fscanf_variation4.phpt:1.1.2.1 
php-src/ext/standard/tests/file/fscanf_variation4.phpt:1.1.2.2
--- php-src/ext/standard/tests/file/fscanf_variation4.phpt:1.1.2.1      Fri Aug 
10 17:54:47 2007
+++ php-src/ext/standard/tests/file/fscanf_variation4.phpt      Tue Jul 22 
14:11:25 2008
@@ -64,7 +64,7 @@
 
 // closing the resources
 fclose($fp);
-fclose($dfp);
+closedir($dfp);
 
 echo "\n*** Done ***";
 ?>
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/fscanf_variation41.phpt?r1=1.1.2.1&r2=1.1.2.2&diff_format=u
Index: php-src/ext/standard/tests/file/fscanf_variation41.phpt
diff -u php-src/ext/standard/tests/file/fscanf_variation41.phpt:1.1.2.1 
php-src/ext/standard/tests/file/fscanf_variation41.phpt:1.1.2.2
--- php-src/ext/standard/tests/file/fscanf_variation41.phpt:1.1.2.1     Fri Aug 
10 17:54:47 2007
+++ php-src/ext/standard/tests/file/fscanf_variation41.phpt     Tue Jul 22 
14:11:25 2008
@@ -63,7 +63,7 @@
 
 // closing the resources
 fclose($fp);
-fclose($dfp);
+closedir($dfp);
 
 echo "\n*** Done ***";
 ?>
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/fscanf_variation47.phpt?r1=1.1.2.1&r2=1.1.2.2&diff_format=u
Index: php-src/ext/standard/tests/file/fscanf_variation47.phpt
diff -u php-src/ext/standard/tests/file/fscanf_variation47.phpt:1.1.2.1 
php-src/ext/standard/tests/file/fscanf_variation47.phpt:1.1.2.2
--- php-src/ext/standard/tests/file/fscanf_variation47.phpt:1.1.2.1     Fri Aug 
10 17:54:48 2007
+++ php-src/ext/standard/tests/file/fscanf_variation47.phpt     Tue Jul 22 
14:11:25 2008
@@ -63,7 +63,7 @@
 
 // closing the resources
 fclose($fp);
-fclose($dfp);
+closedir($dfp);
 
 echo "\n*** Done ***";
 ?>
http://cvs.php.net/viewvc.cgi/php-src/main/php_streams.h?r1=1.103.2.1.2.6&r2=1.103.2.1.2.7&diff_format=u
Index: php-src/main/php_streams.h
diff -u php-src/main/php_streams.h:1.103.2.1.2.6 
php-src/main/php_streams.h:1.103.2.1.2.7
--- php-src/main/php_streams.h:1.103.2.1.2.6    Wed Jun 11 09:02:09 2008
+++ php-src/main/php_streams.h  Tue Jul 22 14:11:25 2008
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_streams.h,v 1.103.2.1.2.6 2008/06/11 09:02:09 dmitry Exp $ */
+/* $Id: php_streams.h,v 1.103.2.1.2.7 2008/07/22 14:11:25 felipe Exp $ */
 
 #ifndef PHP_STREAMS_H
 #define PHP_STREAMS_H
@@ -183,6 +183,8 @@
        
 #define PHP_STREAM_FLAG_IS_DIR                                         64
 
+#define PHP_STREAM_FLAG_FCLOSE                                         128
+
 struct _php_stream  {
        php_stream_ops *ops;
        void *abstract;                 /* convenience pointer for abstraction 
*/
http://cvs.php.net/viewvc.cgi/php-src/sapi/cli/php_cli.c?r1=1.129.2.13.2.24&r2=1.129.2.13.2.25&diff_format=u
Index: php-src/sapi/cli/php_cli.c
diff -u php-src/sapi/cli/php_cli.c:1.129.2.13.2.24 
php-src/sapi/cli/php_cli.c:1.129.2.13.2.25
--- php-src/sapi/cli/php_cli.c:1.129.2.13.2.24  Tue Jan 29 20:01:14 2008
+++ php-src/sapi/cli/php_cli.c  Tue Jul 22 14:11:25 2008
@@ -20,7 +20,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_cli.c,v 1.129.2.13.2.24 2008/01/29 20:01:14 dmitry Exp $ */
+/* $Id: php_cli.c,v 1.129.2.13.2.25 2008/07/22 14:11:25 felipe Exp $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -504,6 +504,10 @@
                if (s_err) php_stream_close(s_err);
                return;
        }
+       
+       s_in->flags  |= PHP_STREAM_FLAG_FCLOSE;
+       s_out->flags |= PHP_STREAM_FLAG_FCLOSE;
+       s_err->flags |= PHP_STREAM_FLAG_FCLOSE;
 
 #if PHP_DEBUG
        /* do not close stdout and stderr */

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to