Bug #68672 [Opn->Nab]: incorrect bit shift

From: Date: Wed, 13 Jul 2016 14:32:44 +0000
Subject: Bug #68672 [Opn->Nab]: incorrect bit shift
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-202283@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=68672&edit=1 ID: 68672 Updated by: dmitry@php.net Reported by: bugreports at internot dot info Summary: incorrect bit shift -Status: Open +Status: Not a bug Type: Bug Package: Scripting Engine problem Operating System: Linux Ubuntu 14.04 PHP Version: master-Git-2014-12-28 (Git) Block user comment: N Private report: N New Comment: zend_strtod.c 1134 if ((y = d1)) { 1135 if ((k = lo0bits(&y))) { 1136 x[0] = y | (z << (32 - k)); 1137 z >>= k; "k" can't be equal to 32, because this means that "y" is equal to zero, but this condition is checked on line 1134. Previous Comments: ------------------------------------------------------------------------ [2014-12-30 02:52:11] aharvey@php.net The shifts in the comments look OK to me (they're explicitly 64 bit integers, and the shift is 61 in both cases), but the zend_strtod.c shift definitely looks like it could be problematic, as lo0bits() can return 32 and ULong (which is the type of z) is a typedef for uint32_t. ------------------------------------------------------------------------ [2014-12-28 23:01:47] bugreports at internot dot info Aswell as: 958 context->count[1] += ((php_hash_uint64) inputLen >> 61); ------------------------------------------------------------------------ [2014-12-28 23:01:08] bugreports at internot dot info And /ext/hash/hash_sha.c: 844 context->count[1] += ((php_hash_uint64) inputLen >> 61); Thanks, ------------------------------------------------------------------------ [2014-12-28 22:56:42] bugreports at internot dot info Description: ------------ Hi, In /Zend/zend_strtod.c: 1137 z >>= k; But k may be 32. Bitshifting >=32 causes "undefined behavior". Thanks, ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=68672&edit=1

« previous php.bugs (#202283) next »