Skip to content

Commit 2871c70

Browse files
libnexweltling
authored andcommitted
Patch for Heap Buffer Overflow in EscapeShell
Proposed patch for bug #71270
1 parent e2565eb commit 2871c70

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ext/standard/exec.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ PHPAPI zend_string *php_escape_shell_cmd(char *str)
253253
#endif
254254

255255

256-
cmd = zend_string_alloc(2 * l, 0);
256+
cmd = zend_string_safe_alloc(2, l, 0, 0);
257257

258258
for (x = 0, y = 0; x < l; x++) {
259259
int mb_len = php_mblen(str + x, (l - x));
@@ -345,7 +345,7 @@ PHPAPI zend_string *php_escape_shell_arg(char *str)
345345
size_t estimate = (4 * l) + 3;
346346

347347

348-
cmd = zend_string_alloc(4 * l + 2, 0); /* worst case */
348+
cmd = zend_string_safe_alloc(4, l, 2, 0); /* worst case */
349349

350350
#ifdef PHP_WIN32
351351
ZSTR_VAL(cmd)[y++] = '"';

0 commit comments

Comments
 (0)