]> The Tcpdump Group git mirrors - libpcap/commit
Don't shift by more than 31 bit positions.
authorGuy Harris <[email protected]>
Tue, 16 Oct 2018 22:57:06 +0000 (15:57 -0700)
committerGuy Harris <[email protected]>
Tue, 16 Oct 2018 22:57:06 +0000 (15:57 -0700)
commitf3dd3f4680d43b6c857a3fbe38c445d28fa62e14
tree47843370fc9fba7477f5c842a06d33c64f1c8600
parenta7f69da5b4939ad107f773eedca07838b05b4fab
Don't shift by more than 31 bit positions.

That's undefined in C, and there are currently-used processors on which
a shift of 32 bits, for example, shifts all the bits out and processors
on which it does no shift (i.e., the shift count is, or isn't, taken
modulo 32).

We'll treat it as shifting all the bits out.

Note that the BPF interpreter doesn't do this test, so the BPF machine's
behavior mirrors the behavior of the processor on which it's running.
We suggest you not write filter expressions, or BPF programs, that rely
on any particular behavior from shifts of more than 31 bits.

Credit to OSS-Fuzz for finding this issue.
optimize.c