iliaa           Mon Sep 15 19:49:42 2003 EDT

  Modified files:              (Branch: PHP_4_3)
    /php-src    NEWS 
    /php-src/ext/bz2    bz2.c 
  Log:
  MFH: Fixed bug #25106 (Added more stringent checks on bzopen() mode).
  
  
Index: php-src/NEWS
diff -u php-src/NEWS:1.1247.2.397 php-src/NEWS:1.1247.2.398
--- php-src/NEWS:1.1247.2.397   Mon Sep 15 00:13:41 2003
+++ php-src/NEWS        Mon Sep 15 19:49:40 2003
@@ -37,6 +37,7 @@
 - Fixed bug #25211 (image.c compile failure with AIX). (Marcus)
 - Fixed bug #25166 (WDDX serializer handler missing in win32). (Jani)
 - Fixed bug #25109 (Possible crash when fetching field names in pgsql). (Ilia)
+- Fixed bug #25106 (Added more stringent checks on bzopen() mode). (Ilia)
 - Fixed bug #25218 ("deflate" compressed pages had a gzip header). (Stefan)
 - Fixed bug #23326 (ext/domxml: Attributes via append_child not supported).
   (Melvyn)
Index: php-src/ext/bz2/bz2.c
diff -u php-src/ext/bz2/bz2.c:1.1.2.1 php-src/ext/bz2/bz2.c:1.1.2.2
--- php-src/ext/bz2/bz2.c:1.1.2.1       Sun Jun 29 19:49:39 2003
+++ php-src/ext/bz2/bz2.c       Mon Sep 15 19:49:41 2003
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
  
-/* $Id: bz2.c,v 1.1.2.1 2003/06/29 23:49:39 edink Exp $ */
+/* $Id: bz2.c,v 1.1.2.2 2003/09/15 23:49:41 iliaa Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -165,9 +165,12 @@
        if (strncasecmp("compress.bzip2://", path, 17) == 0) {
                path += 17;
        }
+       if (mode[0] != 'w' && mode[0] != 'r' && mode[1] != '\0') {
+               return NULL;
+       }
 
 #ifdef VIRTUAL_DIR
-       virtual_filepath(path, &path_copy TSRMLS_CC);
+       virtual_filepath_ex(path, &path_copy, NULL TSRMLS_CC);
 #else
        path_copy = path;
 #endif  
@@ -190,6 +193,12 @@
                                bz_file = BZ2_bzdopen(fd, mode);
                        }
                }
+               /* remove the file created by php_stream_open_wrapper(), it is not 
needed since BZ2 functions
+                * failed.
+                */
+               if (!bz_file && mode[0] == 'w') {
+                       VCWD_UNLINK(*opened_path);
+               }
        }
        
        if (bz_file) {
@@ -302,7 +311,12 @@
                WRONG_PARAM_COUNT;
        }
        convert_to_string_ex(mode);
-       
+
+       if (Z_STRVAL_PP(mode)[0] != 'r' && Z_STRVAL_PP(mode)[0] != 'w' && 
Z_STRVAL_PP(mode)[1] != '\0') {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "'%s' is not a valid mode 
for bzopen(). Only 'w' and 'r' are supported.", Z_STRVAL_PP(mode));
+               RETURN_FALSE;
+       }
+
        /* If it's not a resource its a string containing the filename to open */
        if (Z_TYPE_PP(file) != IS_RESOURCE) {
                convert_to_string_ex(file);

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

Reply via email to