cvs: ZendEngine2(PHP_5_1) / zend_alloc.c
| From: | Ilia Alshanetsky | Date: | Sat, 30 Sep 2006 17:15:23 +0000 |
| Subject: | cvs: ZendEngine2(PHP_5_1) / zend_alloc.c | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-5285@lists.php.net to get a copy of this message | ||
iliaa Sat Sep 30 17:15:23 2006 UTC
Modified files: (Branch: PHP_5_1)
/ZendEngine2 zend_alloc.c
Log:
MFH: Added safety checks against integer overflow.
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_alloc.c?r1=1.144.2.4&r2=1.144.2.5&diff_format=u
Index: ZendEngine2/zend_alloc.c
diff -u ZendEngine2/zend_alloc.c:1.144.2.4 ZendEngine2/zend_alloc.c:1.144.2.5
--- ZendEngine2/zend_alloc.c:1.144.2.4 Thu Aug 10 17:16:24 2006
+++ ZendEngine2/zend_alloc.c Sat Sep 30 17:15:23 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_alloc.c,v 1.144.2.4 2006/08/10 17:16:24 iliaa Exp $ */
+/* $Id: zend_alloc.c,v 1.144.2.5 2006/09/30 17:15:23 iliaa Exp $ */
#include "zend.h"
#include "zend_alloc.h"
@@ -328,15 +328,14 @@
ZEND_API void *_ecalloc(size_t nmemb, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
{
void *p;
- int final_size = size*nmemb;
-
+
HANDLE_BLOCK_INTERRUPTIONS();
- p = _emalloc(final_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
+ p = _safe_emalloc(nmemb, size, 0 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
if (!p) {
HANDLE_UNBLOCK_INTERRUPTIONS();
return (void *) p;
}
- memset(p, 0, final_size);
+ memset(p, 0, size * nmemb);
HANDLE_UNBLOCK_INTERRUPTIONS();
return p;
}