com php-src: We can't stay zend_string->h to be zero , because it may lead to hash value recalcula tion and update. But in general zend_string m ay be
put and read-only memory, that would le ad to crash. Always set the high bit of has h_value to prevent recaclulation.: Zend/zend_st ring.h

From: Date: Tue, 24 Mar 2015 13:28:26 +0000
Subject: com php-src: We can't stay zend_string->h to be zero , because it may lead to hash value recalcula tion and update. But in general zend_string m ay be
put and read-only memory, that would le ad to crash. Always set the high bit of has h_value to prevent recaclulation.: Zend/zend_st ring.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-85840@lists.php.net to get a copy of this message
Commit: bdf7fc67d8a146b4a5387c56268181c63047dfe6 Author: Dmitry Stogov <dmitry@zend.com> Tue, 24 Mar 2015 16:28:26 +0300 Parents: d659ee24ab9246be6ae4d371401d0234579325a0 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=bdf7fc67d8a146b4a5387c56268181c63047dfe6 Log: We can't stay zend_string->h to be zero, because it may lead to hash value recalculation and update. But in general zend_string may be put and read-only memory, that would lead to crash. Always set the high bit of hash_value to prevent recaclulation. Changed paths: M Zend/zend_string.h Diff: diff --git a/Zend/zend_string.h b/Zend/zend_string.h index 29985b7..97528a7 100644 --- a/Zend/zend_string.h +++ b/Zend/zend_string.h @@ -324,7 +324,14 @@ static zend_always_inline zend_ulong zend_inline_hash_func(const char *str, size EMPTY_SWITCH_DEFAULT_CASE() } - return hash; + /* Hash value can't be zero, so we always set the high bit */ +#if SIZEOF_ZEND_LONG == 8 + return hash | Z_UL(0x8000000000000000); +#elif SIZEOF_ZEND_LONG == 4 + return hash | Z_UL(0x80000000); +#else +# error "Unknown SIZEOF_ZEND_LONG" +#endif } static zend_always_inline void zend_interned_empty_string_init(zend_string **s)

« previous php.cvs (#85840) next »