com php-src: Fix shift UB in hash_snefru: ext/hash/hash _snefru.c
| From: | Nikita Popov | Date: | Wed, 19 Jun 2019 13:55:56 +0000 |
| Subject: | com php-src: Fix shift UB in hash_snefru: ext/hash/hash _snefru.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-106913@lists.php.net to get a copy of this message | ||
Commit: 555d68be1067d1757168ec8bbea032c68a13f0ec
Author: Nikita Popov <nikita.ppv@gmail.com> Wed, 19 Jun 2019 15:55:56 +0200
Parents: 88b603768f8e5074ad5cbdccc1e0779089fac9d0
Branches: PHP-7.4 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=555d68be1067d1757168ec8bbea032c68a13f0ec
Log:
Fix shift UB in hash_snefru
Changed paths:
M ext/hash/hash_snefru.c
Diff:
diff --git a/ext/hash/hash_snefru.c b/ext/hash/hash_snefru.c
index 4bca34d..867556a 100644
--- a/ext/hash/hash_snefru.c
+++ b/ext/hash/hash_snefru.c
@@ -123,8 +123,8 @@ static inline void SnefruTransform(PHP_SNEFRU_CTX *context, const unsigned char
int i, j;
for (i = 0, j = 0; i < 32; i += 4, ++j) {
- context->state[8+j] = ((input[i] & 0xff) << 24) | ((input[i+1] & 0xff) <<
16) |
- ((input[i+2] & 0xff) << 8) | (input[i+3] & 0xff);
+ context->state[8+j] = ((unsigned)input[i] << 24) | ((unsigned)input[i+1] << 16) |
+ ((unsigned)input[i+2] << 8) | (unsigned)input[i+3];
}
Snefru(context->state);
ZEND_SECURE_ZERO(&context->state[8], sizeof(uint32_t) * 8);