com php-src: Fixed integer overflow during HashTable size calculation: Zend/zend_types.h
| From: | Dmitry Stogov | Date: | Mon, 01 Jun 2015 07:51:06 +0000 |
| Subject: | com php-src: Fixed integer overflow during HashTable size calculation: Zend/zend_types.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-87033@lists.php.net to get a copy of this message | ||
Commit: 1654442ac3e87388829981d551af6093b229e071
Author: Dmitry Stogov <dmitry@zend.com> Mon, 1 Jun 2015 10:51:06 +0300
Parents: c75ac9e4564d4e434bc43460d0624f572ca52547
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=1654442ac3e87388829981d551af6093b229e071
Log:
Fixed integer overflow during HashTable size calculation
Changed paths:
M Zend/zend_types.h
Diff:
diff --git a/Zend/zend_types.h b/Zend/zend_types.h
index 3834835..c1fceab 100644
--- a/Zend/zend_types.h
+++ b/Zend/zend_types.h
@@ -229,13 +229,13 @@ struct _zend_array {
HT_HASH_EX((ht)->arData, idx)
#define HT_HASH_SIZE(ht) \
- ((-(int32_t)(ht)->nTableMask) * sizeof(uint32_t))
+ (((size_t)(uint32_t)-(int32_t)(ht)->nTableMask) * sizeof(uint32_t))
#define HT_DATA_SIZE(ht) \
- ((ht)->nTableSize * sizeof(Bucket))
+ ((size_t)(ht)->nTableSize * sizeof(Bucket))
#define HT_SIZE(ht) \
(HT_HASH_SIZE(ht) + HT_DATA_SIZE(ht))
#define HT_USED_SIZE(ht) \
- (HT_HASH_SIZE(ht) + ((ht)->nNumUsed * sizeof(Bucket)))
+ (HT_HASH_SIZE(ht) + ((size_t)(ht)->nNumUsed * sizeof(Bucket)))
#define HT_HASH_RESET(ht) \
memset(&HT_HASH(ht, (ht)->nTableMask), HT_INVALID_IDX, HT_HASH_SIZE(ht))
#define HT_HASH_RESET_PACKED(ht) do { \