mirror of
https://github.com/php/php-src.git
synced 2024-12-16 05:15:03 +08:00
MFB: Added missing boundary checks.
This commit is contained in:
parent
2b4e4159db
commit
3482d76823
@ -1107,7 +1107,7 @@ PHPAPI char *php_escape_html_entities(char *orig, int oldlen, int *newlen, int a
|
||||
|
||||
matches_map = 0;
|
||||
|
||||
if (len + 9 > maxlen)
|
||||
if (len + 16 > maxlen)
|
||||
replaced = erealloc (replaced, maxlen += 128);
|
||||
|
||||
if (all) {
|
||||
@ -1132,9 +1132,15 @@ PHPAPI char *php_escape_html_entities(char *orig, int oldlen, int *newlen, int a
|
||||
}
|
||||
|
||||
if (matches_map) {
|
||||
int l = strlen(rep);
|
||||
/* increase the buffer size */
|
||||
if (len + 2 + l >= maxlen) {
|
||||
replaced = erealloc(replaced, maxlen += 128);
|
||||
}
|
||||
|
||||
replaced[len++] = '&';
|
||||
strcpy(replaced + len, rep);
|
||||
len += strlen(rep);
|
||||
len += l;
|
||||
replaced[len++] = ';';
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user