fix clib_mem_unaligned() invalid read 80/8980/1
authorGabriel Ganne <gabriel.ganne@enea.com>
Tue, 24 Oct 2017 07:58:45 +0000 (09:58 +0200)
committerGabriel Ganne <gabriel.ganne@enea.com>
Tue, 24 Oct 2017 08:09:04 +0000 (10:09 +0200)
commit0ed3d81a5fa274283ae69b69a405c385189897d3
treefcafb4623314e6d68c054e89f7216ab2e6a75e62
parent92b0275a364022af6ab828dfac83e38c0117cfe6
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