cvs: ZendEngine2 / zend_operators.c

From: Date: Thu, 29 May 2008 11:44:09 +0000
Subject: cvs: ZendEngine2 / zend_operators.c
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-6754@lists.php.net to get a copy of this message
mattwil Thu May 29 11:44:09 2008 UTC Modified files: /ZendEngine2 zend_operators.c Log: Fixed overflow crash (at least on Windows) in div_function with LONG_MIN / -1 To reproduce: (-PHP_INT_MAX - 1) / -1, so op1 is a long Same cause as Bug #27354 for mod_function http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_operators.c?r1=1.290&r2=1.291&diff_format=u Index: ZendEngine2/zend_operators.c diff -u ZendEngine2/zend_operators.c:1.290 ZendEngine2/zend_operators.c:1.291 --- ZendEngine2/zend_operators.c:1.290 Wed Mar 19 12:40:20 2008 +++ ZendEngine2/zend_operators.c Thu May 29 11:44:09 2008 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_operators.c,v 1.290 2008/03/19 12:40:20 tony2001 Exp $ */ +/* $Id: zend_operators.c,v 1.291 2008/05/29 11:44:09 mattwil Exp $ */ #include <ctype.h> @@ -1454,6 +1454,10 @@ zend_error(E_WARNING, "Division by zero"); ZVAL_BOOL(result, 0); return FAILURE; /* division by zero */ + } else if (Z_LVAL_P(op2) == -1 && Z_LVAL_P(op1) == LONG_MIN) { + /* Prevent overflow error/crash */ + ZVAL_DOUBLE(result, (double) LONG_MIN / -1); + return SUCCESS; } if (Z_LVAL_P(op1) % Z_LVAL_P(op2) == 0) { /* integer */ ZVAL_LONG(result, Z_LVAL_P(op1) / Z_LVAL_P(op2));

« previous php.zend-engine.cvs (#6754) next »