]> The Tcpdump Group git mirrors - libpcap/commit
Do unsigned shifts.
authorGuy Harris <[email protected]>
Fri, 22 Jun 2018 06:11:05 +0000 (23:11 -0700)
committerGuy Harris <[email protected]>
Fri, 22 Jun 2018 06:11:05 +0000 (23:11 -0700)
commitbe18c1521d1436be38a7024ada3ddef95f412554
tree323ebb6153a791f92e5a6bcd7c679ecf5a39709a
parent02fcc94b72560e5ccb5800822178c829965a9256
Do unsigned shifts.

To quote C99 section 6.5.7 "Bitwise shift operators":

The result of E1 << E2 is E1 left-shifted E2 bit positions;
vacated bits are filled with zeros.  ...  If E1 has a signed
type and nonnegative value, and E1 x 2^E2 is representable in
the result type, then that is the resulting value; otherwise,
the behavior is undefined.

In practice, this is harmless, as long as we don't get a trap of some
sort in the "isn't representable" case, but we might as well do an
unsigned shift - it's just doing hashing, so as long as all the relevant
bits get hashed in, that's good enough.

This should keep UBSAN quiet.
optimize.c