Skip to content

Commit 5977610

Browse files
committed
Fix #74544: Integer overflow in mysqli_real_escape_string()
The patch has been provided by @johannes. Closes phpGH-7353.
1 parent 6724d5d commit 5977610

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Diff for: NEWS

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ PHP NEWS
1818
- GD:
1919
. Fixed bug #51498 (imagefilledellipse does not work for large circles). (cmb)
2020

21+
- MySQLi:
22+
. Fixed bug #74544 (Integer overflow in mysqli_real_escape_string()). (cmb,
23+
johannes)
24+
2125
- OpenSSL:
2226
. Fixed bug #81327 (Error build openssl extension on php 7.4.22). (cmb)
2327

Diff for: ext/mysqli/mysqli_api.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1971,7 +1971,7 @@ PHP_FUNCTION(mysqli_real_escape_string) {
19711971
}
19721972
MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_VALID);
19731973

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

0 commit comments

Comments
 (0)