Skip to content
Permalink
Browse files Browse the repository at this point in the history
Fix bug #73807
  • Loading branch information
nikic committed Feb 2, 2017
1 parent 570a273 commit a15bffd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions NEWS
Expand Up @@ -2,6 +2,10 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2017 PHP 7.0.17

- Core:
. Fixed bug #73807 (Performance problem with processing large post request).
(Nikita)

- OpenSSL:
. Fixed bug #74022 (PHP Fast CGI crashes when reading from a pfx file).
(Anatol)
Expand Down
10 changes: 8 additions & 2 deletions main/php_variables.c
Expand Up @@ -239,21 +239,26 @@ typedef struct post_var_data {
char *ptr;
char *end;
uint64_t cnt;

/* Bytes in ptr that have already been scanned for '&' */
size_t already_scanned;
} post_var_data_t;

static zend_bool add_post_var(zval *arr, post_var_data_t *var, zend_bool eof)
{
char *ksep, *vsep, *val;
char *start, *ksep, *vsep, *val;
size_t klen, vlen;
size_t new_vlen;

if (var->ptr >= var->end) {
return 0;
}

vsep = memchr(var->ptr, '&', var->end - var->ptr);
start = var->ptr + var->already_scanned;
vsep = memchr(start, '&', var->end - start);
if (!vsep) {
if (!eof) {
var->already_scanned = var->end - var->ptr;
return 0;
} else {
vsep = var->end;
Expand Down Expand Up @@ -286,6 +291,7 @@ static zend_bool add_post_var(zval *arr, post_var_data_t *var, zend_bool eof)
efree(val);

var->ptr = vsep + (vsep != var->end);
var->already_scanned = 0;
return 1;
}

Expand Down

0 comments on commit a15bffd

Please sign in to comment.