]> git.kaiwu.me - njs.git/commit
Avoid undefined shifts in MurmurHash2
authorDmitry Volyntsev <xeioex@nginx.com>
Thu, 17 Sep 2026 21:51:00 +0000 (14:51 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Fri, 18 Sep 2026 20:42:16 +0000 (13:42 -0700)
commitd05bcb9bd58897578c2f2a7c384add9d87fbc623
tree52de8df1264e6e3921576ea345962de14942aa2f
parenta643c7133e53ea319023a71ae652b3a18805e2a2
Avoid undefined shifts in MurmurHash2

Previously, input bytes were promoted to signed int before being shifted
into a hash word.  A byte with its high bit set could make the 24-bit
shift undefined.

The fix is to cast input bytes to uint32_t before shifting.  This
preserves the hash result and avoids undefined behavior under UBSan.
src/njs_murmur_hash.c