Skip to content

Commit ad08aa3

Browse files
mhagstrandcmb69
authored andcommitted
Fix #70103: Fix bug 70103 when ZTS is enabled
Used snprintf to copy the basename string before it is freed
1 parent ba0751a commit ad08aa3

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

NEWS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ PHP NEWS
1515
. Fixed bug #69442 (closing of fd incorrect when PTS enabled). (jaytaph)
1616

1717
- ZIP:
18-
. Fixed bug #70103 (ZipArchive::addGlob ignores remove_all_path option). (cmb)
18+
. Fixed bug #70103 (ZipArchive::addGlob ignores remove_all_path option). (cmb,
19+
Mitch Hagstrand)
1920

2021
19 Jan 2017 PHP 7.0.15
2122

ext/zip/php_zip.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1699,18 +1699,18 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /*
16991699
zval_ptr_dtor(return_value);
17001700
RETURN_FALSE;
17011701
}
1702-
17031702
snprintf(entry_name_buf, MAXPATHLEN, "%s%s", add_path, file_stripped);
1704-
entry_name = entry_name_buf;
1705-
entry_name_len = strlen(entry_name);
17061703
} else {
1707-
entry_name = file_stripped;
1708-
entry_name_len = file_stripped_len;
1704+
snprintf(entry_name_buf, MAXPATHLEN, "%s", file_stripped);
17091705
}
1706+
1707+
entry_name = entry_name_buf;
1708+
entry_name_len = strlen(entry_name);
17101709
if (basename) {
17111710
zend_string_release(basename);
17121711
basename = NULL;
17131712
}
1713+
17141714
if (php_zip_add_file(intern, Z_STRVAL_P(zval_file), Z_STRLEN_P(zval_file),
17151715
entry_name, entry_name_len, 0, 0) < 0) {
17161716
zval_dtor(return_value);

0 commit comments

Comments
 (0)