com php-src: Fixed segfault (op2 maybe equal to result): Zend/zend_operators.c
| From: | Dmitry Stogov | Date: | Wed, 05 Mar 2014 07:43:57 +0000 |
| Subject: | com php-src: Fixed segfault (op2 maybe equal to result): Zend/zend_operators.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-77745@lists.php.net to get a copy of this message | ||
Commit: dc889b69ef8947a87a93a59a24013d972b313158
Author: Xinchen Hui <laruence@gmail.com> Wed, 5 Mar 2014 15:42:57 +0800
Parents: dd7c7e6fb2f8a172fc7d1ee2a9e5fcbb71366603
Branches: phpng
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=dc889b69ef8947a87a93a59a24013d972b313158
Log:
Fixed segfault (op2 maybe equal to result)
Changed paths:
M Zend/zend_operators.c
Diff:
diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c
index 2c3d657..5e9ad6a 100644
--- a/Zend/zend_operators.c
+++ b/Zend/zend_operators.c
@@ -1389,16 +1389,17 @@ ZEND_API int concat_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
/* {{
}
if (result==op1 && !IS_INTERNED(Z_STR_P(op1))) { /* special case, perform operations on
result */
uint op1_len = Z_STRLEN_P(op1);
- uint res_len = op1_len + Z_STRLEN_P(op2);
+ uint op2_len = Z_STRLEN_P(op2);
+ uint res_len = op1_len + op2_len;
- if (Z_STRLEN_P(result) < 0 || (int) (Z_STRLEN_P(op1) + Z_STRLEN_P(op2)) < 0) {
+ if (Z_STRLEN_P(result) < 0 || (int) (op1_len + op2_len) < 0) {
ZVAL_EMPTY_STRING(result);
zend_error(E_ERROR, "String size overflow");
}
Z_STR_P(result) = STR_REALLOC(Z_STR_P(result), res_len, 0 );
- memcpy(Z_STRVAL_P(result) + op1_len, Z_STRVAL_P(op2), Z_STRLEN_P(op2));
+ memcpy(Z_STRVAL_P(result) + op1_len, Z_STRVAL_P(op2), op2_len);
Z_STRVAL_P(result)[res_len]=0;
} else {
int length = Z_STRLEN_P(op1) + Z_STRLEN_P(op2);