mirror of
https://github.com/php/php-src.git
synced 2024-11-23 18:04:36 +08:00
Fix #79812: Potential integer overflow in pcntl_exec()
We use the proper type, and make sure that no overflow can occur by using `safe_emalloc()` (we can assume that neither string length is `SIZE_MAX`). Closes GH-6845.
This commit is contained in:
parent
a04fac84e7
commit
0a36d417e8
3
NEWS
3
NEWS
@ -21,6 +21,9 @@ PHP NEWS
|
||||
- LibXML:
|
||||
. Fixed bug #73533 (Invalid memory access in php_libxml_xmlCheckUTF8). (cmb)
|
||||
|
||||
- Pcntl:
|
||||
. Fixed bug #79812 (Potential integer overflow in pcntl_exec()). (cmb)
|
||||
|
||||
- PDO_ODBC:
|
||||
. Fixed bug #80783 (PDO ODBC truncates BLOB records at every 256th byte).
|
||||
(cmb)
|
||||
|
@ -955,7 +955,7 @@ PHP_FUNCTION(pcntl_exec)
|
||||
int envc = 0, envi = 0;
|
||||
char **argv = NULL, **envp = NULL;
|
||||
char **current_arg, **pair;
|
||||
int pair_length;
|
||||
size_t pair_length;
|
||||
zend_string *key;
|
||||
char *path;
|
||||
size_t path_len;
|
||||
@ -1015,8 +1015,9 @@ PHP_FUNCTION(pcntl_exec)
|
||||
}
|
||||
|
||||
/* Length of element + equal sign + length of key + null */
|
||||
ZEND_ASSERT(Z_STRLEN_P(element) < SIZE_MAX && ZSTR_LEN(key) < SIZE_MAX);
|
||||
*pair = safe_emalloc(Z_STRLEN_P(element) + 1, sizeof(char), ZSTR_LEN(key) + 1);
|
||||
pair_length = Z_STRLEN_P(element) + ZSTR_LEN(key) + 2;
|
||||
*pair = emalloc(pair_length);
|
||||
strlcpy(*pair, ZSTR_VAL(key), ZSTR_LEN(key) + 1);
|
||||
strlcat(*pair, "=", pair_length);
|
||||
strlcat(*pair, Z_STRVAL_P(element), pair_length);
|
||||
|
Loading…
Reference in New Issue
Block a user