cvs: ZendEngine2(PHP_5_2) / zend_operators.c
| From: | Matt Wilmas | Date: | Thu, 29 May 2008 11:45:28 +0000 |
| Subject: | cvs: ZendEngine2(PHP_5_2) / zend_operators.c | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-6756@lists.php.net to get a copy of this message | ||
mattwil Thu May 29 11:45:28 2008 UTC
Modified files: (Branch: PHP_5_2)
/ZendEngine2 zend_operators.c
Log:
MFH: Fixed overflow crash (at least on Windows) in div_function with LONG_MIN / -1
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_operators.c?r1=1.208.2.4.2.24&r2=1.208.2.4.2.25&diff_format=u
Index: ZendEngine2/zend_operators.c
diff -u ZendEngine2/zend_operators.c:1.208.2.4.2.24 ZendEngine2/zend_operators.c:1.208.2.4.2.25
--- ZendEngine2/zend_operators.c:1.208.2.4.2.24 Mon Dec 31 07:20:03 2007
+++ ZendEngine2/zend_operators.c Thu May 29 11:45:28 2008
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_operators.c,v 1.208.2.4.2.24 2007/12/31 07:20:03 sebastian Exp $ */
+/* $Id: zend_operators.c,v 1.208.2.4.2.25 2008/05/29 11:45:28 mattwil Exp $ */
#include <ctype.h>
@@ -891,6 +891,11 @@
return FAILURE; /* division by zero */
}
if (op1->type == IS_LONG && op2->type == IS_LONG) {
+ 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 (op1->value.lval % op2->value.lval == 0) { /* integer */
result->type = IS_LONG;
result->value.lval = op1->value.lval / op2->value.lval;