1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

phar: Avoid string duplication just for error message, use truncation formatting string (#20229)

This commit is contained in:
Niels Dossche
2025-10-20 20:31:16 +02:00
committed by GitHub
parent 45a50d0d68
commit 40b3f88426

View File

@@ -4315,10 +4315,7 @@ PHP_METHOD(Phar, extractTo)
}
if (ZSTR_LEN(path_to) >= MAXPATHLEN) {
char *tmp = estrndup(ZSTR_VAL(path_to), 50);
/* truncate for error message */
zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, "Cannot extract to \"%s...\", destination directory is too long for filesystem", tmp);
efree(tmp);
zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, "Cannot extract to \"%.50s...\", destination directory is too long for filesystem", ZSTR_VAL(path_to));
RETURN_THROWS();
}