summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2006-09-30 17:15:23 +0000
committerIlia Alshanetsky <iliaa@php.net>2006-09-30 17:15:23 +0000
commit9ee2f36780334c53ad5358ffddd9ab0475ed5d87 (patch)
tree938f1a690644270909e04229f8637a9cc1e432fa
parent008302a0dd1e7f3b41ca539f5b45581805a40112 (diff)
downloadphp-git-9ee2f36780334c53ad5358ffddd9ab0475ed5d87.tar.gz
MFH: Added safety checks against integer overflow.
-rw-r--r--Zend/zend_alloc.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c
index 3de98292f0..82b6b9cb52 100644
--- a/Zend/zend_alloc.c
+++ b/Zend/zend_alloc.c
@@ -328,15 +328,14 @@ ZEND_API void _efree(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
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;
}