fix clib_mem_unaligned() invalid read 80/8980/2
authorGabriel Ganne <gabriel.ganne@enea.com>
Tue, 24 Oct 2017 07:58:45 +0000 (09:58 +0200)
committerDave Barach <openvpp@barachs.net>
Wed, 1 Nov 2017 10:06:19 +0000 (10:06 +0000)
commit53ae29e0608868be4f6a9cced21c39e72e294d0b
tree3bd13676023e9974231eb51e345a9ea6f8ef36fc
parent2e2a0ebf0b3b30a8e8d0e39de5b0fdc3b82ab14c
fix clib_mem_unaligned() invalid read

clib_mem_unaligned + zap64 casts its input as u64, computes a mask
according to the input length, and returns the casted maked value.
Therefore all the 8 Bytes of the u64 are systematically read, and
the invalid ones are discarded.
For example, for a 5-Bytes string, we will do an invalid read of size 3,
even though those 3 Bytes are never used.

This patch proposes to only read what we have at the cost of reading as
a u64 in one call, but that way, we do not trigger an invalid read
error.

Change-Id: I3e0b31c4113d9c8e53aa5fa3d3d396ec80f06a27
Signed-off-by: Gabriel Ganne <gabriel.ganne@enea.com>
src/vppinfra/hash.c