Commit 87258eb2676 for php.net
commit 87258eb2676e3847573b0f02277d6b7dc46415b8
Author: Jakub Zelenka <bukka@php.net>
Date: Mon May 4 02:36:50 2026 +0200
ext/phar: Fix path overread from recent refactoring (#21943)
This is from unrelased refactoring: e1c5049#diff-04979daf330cd412502ec8ebf4a363d608a73f034687a0dd07328fd0969f2813L2070-R2069 . It was a clear mistake that can lead to the over-read.
diff --git a/ext/phar/phar.c b/ext/phar/phar.c
index ef25e9c3192..38c4bb26ff8 100644
--- a/ext/phar/phar.c
+++ b/ext/phar/phar.c
@@ -2074,7 +2074,7 @@ zend_string* phar_fix_filepath(const char *path, size_t path_length, bool use_cw
size_t ptr_length;
if (use_cwd && PHAR_G(cwd_len) && path_length > 2 && path[0] == '.' && path[1] == '/') {
- new_path = zend_string_alloc(path_length + path_length + 1, false);
+ new_path = zend_string_alloc(path_length + PHAR_G(cwd_len) + 1, false);
new_path_len = PHAR_G(cwd_len);
memcpy(ZSTR_VAL(new_path), PHAR_G(cwd), PHAR_G(cwd_len));
} else {