]> The Tcpdump Group git mirrors - tcpdump/commit
Try to get Coverity to shut up about "tainted" values.
authorGuy Harris <[email protected]>
Wed, 3 Jul 2019 06:23:14 +0000 (23:23 -0700)
committerGuy Harris <[email protected]>
Wed, 3 Jul 2019 06:23:14 +0000 (23:23 -0700)
commitcee18d339ad10857bb5b546a1725744a39b113fe
tree7cad09eceb27888fc05fde8769990f240b55a287
parentbea5ccb05c9c161e0e57de0b6ec51858ae53653b
Try to get Coverity to shut up about "tainted" values.

Hello, Coverity.  A uint8_t is 8 bits long, and is unsigned; if you
shift it right by 4 bits, the result is the lower 4 bits.  4 bits can
represent values from 0 to 15, so YOU CAN BE CERTAIN THAT SAID VALUE CAN
SAFELY BE USED AS AN INDEX INTO AN ARRAY WITH 16 ELEMENTS.

Extract the value into a uint8_t, to see if *that* allows Coverity to
see that (rather than saying "ZOMG THAT CONVERTS TO AN int AND IT'S NOT
MASKED WITH 0xf IT MIGHT BE OUT OF RANGE DANGER DANGER WILL ROBINSON").
If not, we may just have to mask it with 0xf to pacify Coverity.

The resulting code also flows a bit better - no auto-incrementation in
the subscript operation, and the fetching being done separately from the
conversion to hex.

Should address Coverity CID 1449413, and possibly others.
addrtoname.c