Skip to content

Commit

Permalink
Fix #74544: Integer overflow in mysqli_real_escape_string()
Browse files Browse the repository at this point in the history
The patch has been provided by @johannes.

Closes GH-7353.
  • Loading branch information
cmb69 committed Aug 9, 2021
1 parent 6724d5d commit 5977610
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ PHP NEWS
- GD:
. Fixed bug #51498 (imagefilledellipse does not work for large circles). (cmb)

- MySQLi:
. Fixed bug #74544 (Integer overflow in mysqli_real_escape_string()). (cmb,
johannes)

- OpenSSL:
. Fixed bug #81327 (Error build openssl extension on php 7.4.22). (cmb)

Expand Down
2 changes: 1 addition & 1 deletion ext/mysqli/mysqli_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1971,7 +1971,7 @@ PHP_FUNCTION(mysqli_real_escape_string) {
}
MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_VALID);

newstr = zend_string_alloc(2 * escapestr_len, 0);
newstr = zend_string_safe_alloc(2, escapestr_len, 0, 0);
ZSTR_LEN(newstr) = mysql_real_escape_string_quote(mysql->mysql, ZSTR_VAL(newstr), escapestr, escapestr_len, '\'');
newstr = zend_string_truncate(newstr, ZSTR_LEN(newstr), 0);

Expand Down

0 comments on commit 5977610

Please sign in to comment.