]> granicus.if.org Git - php/commitdiff
Fix #70103: Fix bug 70103 when ZTS is enabled
authorMitch Hagstrand <mhagstrand@gmail.com>
Fri, 6 Jan 2017 10:14:12 +0000 (02:14 -0800)
committerChristoph M. Becker <cmbecker69@gmx.de>
Fri, 6 Jan 2017 14:26:17 +0000 (15:26 +0100)
Used snprintf to copy the basename string before it is freed

NEWS
ext/zip/php_zip.c

diff --git a/NEWS b/NEWS
index 3d7a45f027f13014ea5e88aa07dcf2b061fcecf7..d19ab0d5cf49834ed6bb00001d2a1d64f5c17017 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -15,7 +15,8 @@ PHP                                                                        NEWS
   . Fixed bug #69442 (closing of fd incorrect when PTS enabled). (jaytaph)
 
 - ZIP:
-  . Fixed bug #70103 (ZipArchive::addGlob ignores remove_all_path option). (cmb)
+       . Fixed bug #70103 (ZipArchive::addGlob ignores remove_all_path option). (cmb,
+         Mitch Hagstrand)
 
 19 Jan 2017 PHP 7.0.15
 
index 67204b08b4759b9fe9120cdd7f0774389199b80d..20c4e86de0bd5853e7dcf7a63ce29f1b02f8e22b 100644 (file)
@@ -1699,18 +1699,18 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /*
                                                zval_ptr_dtor(return_value);
                                                RETURN_FALSE;
                                        }
-
                                        snprintf(entry_name_buf, MAXPATHLEN, "%s%s", add_path, file_stripped);
-                                       entry_name = entry_name_buf;
-                                       entry_name_len = strlen(entry_name);
                                } else {
-                                       entry_name = file_stripped;
-                                       entry_name_len = file_stripped_len;
+                                       snprintf(entry_name_buf, MAXPATHLEN, "%s", file_stripped);
                                }
+
+                               entry_name = entry_name_buf;
+                               entry_name_len = strlen(entry_name);
                                if (basename) {
                                        zend_string_release(basename);
                                        basename = NULL;
                                }
+
                                if (php_zip_add_file(intern, Z_STRVAL_P(zval_file), Z_STRLEN_P(zval_file),
                                        entry_name, entry_name_len, 0, 0) < 0) {
                                        zval_dtor(return_value);