mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Fix GHSA-5hqh-c84r-qjcv: Integer overflow in the firebird quoter causing OOB writes
This commit is contained in:
parent
d9baa9fed8
commit
69c5f68fdc
1 changed files with 5 additions and 1 deletions
|
@ -662,7 +662,7 @@ free_statement:
|
||||||
/* called by the PDO SQL parser to add quotes to values that are copied into SQL */
|
/* called by the PDO SQL parser to add quotes to values that are copied into SQL */
|
||||||
static zend_string* firebird_handle_quoter(pdo_dbh_t *dbh, const zend_string *unquoted, enum pdo_param_type paramtype)
|
static zend_string* firebird_handle_quoter(pdo_dbh_t *dbh, const zend_string *unquoted, enum pdo_param_type paramtype)
|
||||||
{
|
{
|
||||||
int qcount = 0;
|
size_t qcount = 0;
|
||||||
char const *co, *l, *r;
|
char const *co, *l, *r;
|
||||||
char *c;
|
char *c;
|
||||||
size_t quotedlen;
|
size_t quotedlen;
|
||||||
|
@ -676,6 +676,10 @@ static zend_string* firebird_handle_quoter(pdo_dbh_t *dbh, const zend_string *un
|
||||||
/* count the number of ' characters */
|
/* count the number of ' characters */
|
||||||
for (co = ZSTR_VAL(unquoted); (co = strchr(co,'\'')); qcount++, co++);
|
for (co = ZSTR_VAL(unquoted); (co = strchr(co,'\'')); qcount++, co++);
|
||||||
|
|
||||||
|
if (UNEXPECTED(ZSTR_LEN(unquoted) + 2 > ZSTR_MAX_LEN - qcount)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
quotedlen = ZSTR_LEN(unquoted) + qcount + 2;
|
quotedlen = ZSTR_LEN(unquoted) + qcount + 2;
|
||||||
quoted_str = zend_string_alloc(quotedlen, 0);
|
quoted_str = zend_string_alloc(quotedlen, 0);
|
||||||
c = ZSTR_VAL(quoted_str);
|
c = ZSTR_VAL(quoted_str);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue