mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02: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
2 changed files with 6 additions and 2 deletions
3
NEWS
3
NEWS
|
@ -21,6 +21,9 @@ PHP NEWS
|
||||||
- LibXML:
|
- LibXML:
|
||||||
. Fixed bug #73533 (Invalid memory access in php_libxml_xmlCheckUTF8). (cmb)
|
. Fixed bug #73533 (Invalid memory access in php_libxml_xmlCheckUTF8). (cmb)
|
||||||
|
|
||||||
|
- Pcntl:
|
||||||
|
. Fixed bug #79812 (Potential integer overflow in pcntl_exec()). (cmb)
|
||||||
|
|
||||||
- PDO_ODBC:
|
- PDO_ODBC:
|
||||||
. Fixed bug #80783 (PDO ODBC truncates BLOB records at every 256th byte).
|
. Fixed bug #80783 (PDO ODBC truncates BLOB records at every 256th byte).
|
||||||
(cmb)
|
(cmb)
|
||||||
|
|
|
@ -955,7 +955,7 @@ PHP_FUNCTION(pcntl_exec)
|
||||||
int envc = 0, envi = 0;
|
int envc = 0, envi = 0;
|
||||||
char **argv = NULL, **envp = NULL;
|
char **argv = NULL, **envp = NULL;
|
||||||
char **current_arg, **pair;
|
char **current_arg, **pair;
|
||||||
int pair_length;
|
size_t pair_length;
|
||||||
zend_string *key;
|
zend_string *key;
|
||||||
char *path;
|
char *path;
|
||||||
size_t path_len;
|
size_t path_len;
|
||||||
|
@ -1015,8 +1015,9 @@ PHP_FUNCTION(pcntl_exec)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Length of element + equal sign + length of key + null */
|
/* 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_length = Z_STRLEN_P(element) + ZSTR_LEN(key) + 2;
|
||||||
*pair = emalloc(pair_length);
|
|
||||||
strlcpy(*pair, ZSTR_VAL(key), ZSTR_LEN(key) + 1);
|
strlcpy(*pair, ZSTR_VAL(key), ZSTR_LEN(key) + 1);
|
||||||
strlcat(*pair, "=", pair_length);
|
strlcat(*pair, "=", pair_length);
|
||||||
strlcat(*pair, Z_STRVAL_P(element), pair_length);
|
strlcat(*pair, Z_STRVAL_P(element), pair_length);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue