felipe          Tue Jul 22 14:06:17 2008 UTC

  Modified files:              
    /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/ext/standard/tests/strings sprintf_variation23.phpt 
    /php-src/main       php_streams.h 
    /php-src/sapi/cli   php_cli.c 
  Log:
  - 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.520&r2=1.521&diff_format=u
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.520 php-src/ext/standard/file.c:1.521
--- php-src/ext/standard/file.c:1.520   Fri Jul 11 10:24:29 2008
+++ php-src/ext/standard/file.c Tue Jul 22 14:06:16 2008
@@ -21,7 +21,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: file.c,v 1.520 2008/07/11 10:24:29 tony2001 Exp $ */
+/* $Id: file.c,v 1.521 2008/07/22 14:06:16 felipe Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -965,6 +965,8 @@
        stream = php_stream_fopen_tmpfile();
 
        if (stream) {
+               stream->flags |= PHP_STREAM_FLAG_FCLOSE;
+
                php_stream_to_zval(stream, return_value);
        } else {
                RETURN_FALSE;
@@ -998,6 +1000,8 @@
        if (stream == NULL) {
                RETURN_FALSE;
        }
+       
+       stream->flags |= PHP_STREAM_FLAG_FCLOSE;
 
        php_stream_to_zval(stream, return_value);
 }
@@ -1015,6 +1019,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.127&r2=1.128&diff_format=u
Index: php-src/ext/standard/fsock.c
diff -u php-src/ext/standard/fsock.c:1.127 php-src/ext/standard/fsock.c:1.128
--- php-src/ext/standard/fsock.c:1.127  Mon Dec 31 07:12:15 2007
+++ php-src/ext/standard/fsock.c        Tue Jul 22 14:06:16 2008
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: fsock.c,v 1.127 2007/12/31 07:12:15 sebastian Exp $ */
+/* $Id: fsock.c,v 1.128 2008/07/22 14:06:16 felipe Exp $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -79,6 +79,8 @@
        stream = php_stream_xport_create(hostname, hostname_len, 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.61&r2=1.62&diff_format=u
Index: php-src/ext/standard/proc_open.c
diff -u php-src/ext/standard/proc_open.c:1.61 
php-src/ext/standard/proc_open.c:1.62
--- php-src/ext/standard/proc_open.c:1.61       Tue Apr  8 08:42:05 2008
+++ php-src/ext/standard/proc_open.c    Tue Jul 22 14:06:16 2008
@@ -15,7 +15,7 @@
    | Author: Wez Furlong <[EMAIL PROTECTED]>                           |
    +----------------------------------------------------------------------+
  */
-/* $Id: proc_open.c,v 1.61 2008/04/08 08:42:05 jani Exp $ */
+/* $Id: proc_open.c,v 1.62 2008/07/22 14:06:16 felipe Exp $ */
 
 #if 0 && (defined(__linux__) || defined(sun) || defined(__IRIX__))
 # define _BSD_SOURCE           /* linux wants this when XOPEN mode is on */
@@ -971,7 +971,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;
 
                                        if (UG(unicode) && !binary_pipes) {
                                                if (write_stream) {
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/streamsfuncs.c?r1=1.118&r2=1.119&diff_format=u
Index: php-src/ext/standard/streamsfuncs.c
diff -u php-src/ext/standard/streamsfuncs.c:1.118 
php-src/ext/standard/streamsfuncs.c:1.119
--- php-src/ext/standard/streamsfuncs.c:1.118   Mon Jul 21 14:29:46 2008
+++ php-src/ext/standard/streamsfuncs.c Tue Jul 22 14:06:16 2008
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: streamsfuncs.c,v 1.118 2008/07/21 14:29:46 felipe Exp $ */
+/* $Id: streamsfuncs.c,v 1.119 2008/07/22 14:06:16 felipe Exp $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -126,6 +126,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 */
@@ -155,6 +156,8 @@
                RETURN_FALSE;
        }
        
+       stream->flags |= PHP_STREAM_FLAG_FCLOSE;
+       
        if (errstr) {
                efree(errstr);
        }
@@ -201,6 +204,8 @@
        stream = php_stream_xport_create(host, host_len, 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);
@@ -267,7 +272,9 @@
                                NULL, NULL,
                                &tv, &errstr
                                TSRMLS_CC) && clistream) {
-
+               
+               clistream->flags |= PHP_STREAM_FLAG_FCLOSE;
+               
                if (peername) {
                        ZVAL_RT_STRINGL(zpeername, peername, peername_len, 
ZSTR_AUTOFREE);
                }
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/fscanf_variation10.phpt?r1=1.3&r2=1.4&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.3 
php-src/ext/standard/tests/file/fscanf_variation10.phpt:1.4
--- php-src/ext/standard/tests/file/fscanf_variation10.phpt:1.3 Tue May 27 
09:34:53 2008
+++ php-src/ext/standard/tests/file/fscanf_variation10.phpt     Tue Jul 22 
14:06:16 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.3&r2=1.4&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.3 
php-src/ext/standard/tests/file/fscanf_variation16.phpt:1.4
--- php-src/ext/standard/tests/file/fscanf_variation16.phpt:1.3 Tue May 27 
09:34:53 2008
+++ php-src/ext/standard/tests/file/fscanf_variation16.phpt     Tue Jul 22 
14:06:16 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.3&r2=1.4&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.3 
php-src/ext/standard/tests/file/fscanf_variation22.phpt:1.4
--- php-src/ext/standard/tests/file/fscanf_variation22.phpt:1.3 Tue May 27 
09:34:53 2008
+++ php-src/ext/standard/tests/file/fscanf_variation22.phpt     Tue Jul 22 
14:06:16 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.3&r2=1.4&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.3 
php-src/ext/standard/tests/file/fscanf_variation29.phpt:1.4
--- php-src/ext/standard/tests/file/fscanf_variation29.phpt:1.3 Tue May 27 
09:34:53 2008
+++ php-src/ext/standard/tests/file/fscanf_variation29.phpt     Tue Jul 22 
14:06:16 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.3&r2=1.4&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.3 
php-src/ext/standard/tests/file/fscanf_variation35.phpt:1.4
--- php-src/ext/standard/tests/file/fscanf_variation35.phpt:1.3 Tue May 27 
09:34:53 2008
+++ php-src/ext/standard/tests/file/fscanf_variation35.phpt     Tue Jul 22 
14:06:16 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.3&r2=1.4&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.3 
php-src/ext/standard/tests/file/fscanf_variation4.phpt:1.4
--- php-src/ext/standard/tests/file/fscanf_variation4.phpt:1.3  Tue May 27 
09:34:53 2008
+++ php-src/ext/standard/tests/file/fscanf_variation4.phpt      Tue Jul 22 
14:06:16 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.3&r2=1.4&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.3 
php-src/ext/standard/tests/file/fscanf_variation41.phpt:1.4
--- php-src/ext/standard/tests/file/fscanf_variation41.phpt:1.3 Tue May 27 
09:34:53 2008
+++ php-src/ext/standard/tests/file/fscanf_variation41.phpt     Tue Jul 22 
14:06:16 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.3&r2=1.4&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.3 
php-src/ext/standard/tests/file/fscanf_variation47.phpt:1.4
--- php-src/ext/standard/tests/file/fscanf_variation47.phpt:1.3 Tue May 27 
09:34:53 2008
+++ php-src/ext/standard/tests/file/fscanf_variation47.phpt     Tue Jul 22 
14:06:17 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/strings/sprintf_variation23.phpt?r1=1.3&r2=1.4&diff_format=u
Index: php-src/ext/standard/tests/strings/sprintf_variation23.phpt
diff -u php-src/ext/standard/tests/strings/sprintf_variation23.phpt:1.3 
php-src/ext/standard/tests/strings/sprintf_variation23.phpt:1.4
--- php-src/ext/standard/tests/strings/sprintf_variation23.phpt:1.3     Tue May 
27 10:50:46 2008
+++ php-src/ext/standard/tests/strings/sprintf_variation23.phpt Tue Jul 22 
14:06:17 2008
@@ -39,7 +39,7 @@
 
 // closing the resources
 fclose($fp);
-fclose($dfp);
+closedir($dfp);
 
 echo "Done";
 ?>
http://cvs.php.net/viewvc.cgi/php-src/main/php_streams.h?r1=1.135&r2=1.136&diff_format=u
Index: php-src/main/php_streams.h
diff -u php-src/main/php_streams.h:1.135 php-src/main/php_streams.h:1.136
--- php-src/main/php_streams.h:1.135    Wed Jun 11 09:01:44 2008
+++ php-src/main/php_streams.h  Tue Jul 22 14:06:17 2008
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_streams.h,v 1.135 2008/06/11 09:01:44 dmitry Exp $ */
+/* $Id: php_streams.h,v 1.136 2008/07/22 14:06:17 felipe Exp $ */
 
 #ifndef PHP_STREAMS_H
 #define PHP_STREAMS_H
@@ -191,6 +191,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.189&r2=1.190&diff_format=u
Index: php-src/sapi/cli/php_cli.c
diff -u php-src/sapi/cli/php_cli.c:1.189 php-src/sapi/cli/php_cli.c:1.190
--- php-src/sapi/cli/php_cli.c:1.189    Wed Mar 26 14:46:17 2008
+++ php-src/sapi/cli/php_cli.c  Tue Jul 22 14:06:17 2008
@@ -20,7 +20,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_cli.c,v 1.189 2008/03/26 14:46:17 scottmac Exp $ */
+/* $Id: php_cli.c,v 1.190 2008/07/22 14:06:17 felipe Exp $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -516,6 +516,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