Wireshark-commits: [Wireshark-commits] master dba1751: Make it more obvious why no bounds checks ar
URL: https://code.wireshark.org/review/gitweb?p=wireshark.git;a=commit;h=dba17518dfd611f84e87a95143f1058e05bca9f8
Submitter: Guy Harris (guy@xxxxxxxxxxxx)
Changed: branch: master
Repository: wireshark
Commits:
dba1751 by Guy Harris (guy@xxxxxxxxxxxx):
Make it more obvious why no bounds checks are necessary for 11n.
For unsigned x, x/8 is x >> 3, and x*8 is x << 3, so 8*(x/8) is the result
of shifting x right 3 bits and then left 3 bits, which is the same as
masking out the low-order 3 bits, and x - (8*x/8) is the result of
subtracting all but the low-order 3 bits from x, thus it's the lower 3
bits, so you can just mask it with 0x7. That means the result is in the
range 0 through 7, so as long as the array has 8 elements, you're OK; it
does, but explicitly declare it as such, to make it clearer that it is,
and to get compiler warnings if not all 8 elements are initialized.
Change-Id: Iff9c0626b9bdc012cca52e4160dda9e947315bc4
Reviewed-on: https://code.wireshark.org/review/12264
Reviewed-by: Guy Harris <guy@xxxxxxxxxxxx>
Actions performed:
from b8fa3d4 vwr: fix buffer overrun in getRate
adds dba1751 Make it more obvious why no bounds checks are necessary for 11n.
Summary of changes:
wiretap/vwr.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)