com php-src: Fix bug #73807: main/php_variables.c

From: Date: Tue, 20 Jun 2017 07:23:44 +0000
Subject: com php-src: Fix bug #73807: main/php_variables.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-98117@lists.php.net to get a copy of this message
Commit: 0f8cf3b8497dc45c010c44ed9e96518e11e19fc3 Author: Nikita Popov <nikita.ppv@gmail.com> Thu, 2 Feb 2017 16:04:02 +0100 Committer: Stanislav Malyshev <stas@php.net> Tue, 20 Jun 2017 00:23:44 -0700 Parents: 0e21d8066b940e1228fa840a1539ca3434dc3a3f Branches: PHP-5.6 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=0f8cf3b8497dc45c010c44ed9e96518e11e19fc3 Log: Fix bug #73807 Bugs: https://bugs.php.net/73807 Changed paths: M main/php_variables.c Diff: diff --git a/main/php_variables.c b/main/php_variables.c index 018e906..6da79bd 100644 --- a/main/php_variables.c +++ b/main/php_variables.c @@ -237,11 +237,14 @@ 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 TSRMLS_DC) { - char *ksep, *vsep, *val; + char *start, *ksep, *vsep, *val; size_t klen, vlen; /* FIXME: string-size_t */ unsigned int new_vlen; @@ -250,9 +253,11 @@ static zend_bool add_post_var(zval *arr, post_var_data_t *var, zend_bool eof TSR 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; @@ -285,6 +290,7 @@ static zend_bool add_post_var(zval *arr, post_var_data_t *var, zend_bool eof TSR efree(val); var->ptr = vsep + (vsep != var->end); + var->already_scanned = 0; return 1; } @@ -304,7 +310,7 @@ static inline int add_post_vars(zval *arr, post_var_data_t *vars, zend_bool eof } } - if (!eof) { + if (!eof && vars->str.c != vars->ptr) { memmove(vars->str.c, vars->ptr, vars->str.len = vars->end - vars->ptr); } return SUCCESS;

« previous php.cvs (#98117) next »