Skip to content

Integer overflow in the firebird and dblib quoters causing OOB writes

Moderate
bukka published GHSA-5hqh-c84r-qjcv Nov 21, 2024

Package

No package listed

Affected versions

< 8.1.31
< 8.2.26
< 8.3.14

Patched versions

8.1.31
8.2.26
8.3.14

Description

Impact

The following code:

for (co = ZSTR_VAL(unquoted); (co = strchr(co,'\'')); qcount++, co++);
quotedlen = ZSTR_LEN(unquoted) + qcount + 2;
quoted_str = zend_string_alloc(quotedlen, 0);

and the following code:

/* Detect quoted length, adding extra char for doubled single quotes */
for (i = 0; i < ZSTR_LEN(unquoted); i++) {
if (ZSTR_VAL(unquoted)[i] == '\'') ++quotedlen;
++quotedlen;
}
quotedlen += 2; /* +2 for opening, closing quotes */
if (use_national_character_set) {
++quotedlen; /* N prefix */
}
quoted_str = zend_string_alloc(quotedlen, 0);

Can cause integer overflow, or can become a value over ZSTR_MAX_LEN causing an overflow, which eventually turns into an OOB write. This is triggerable on 32-bit especially.

Severity

Moderate

CVE ID

CVE-2024-11236

Weaknesses

No CWEs