Wireshark mailing list archives

Re: [Wireshark-commits] rev 51395: /trunk/epan/dissectors/ /trunk/epan/dissectors/: packet-rohc.c


From: Guy Harris <guy () alum mit edu>
Date: Sat, 17 Aug 2013 11:08:20 -0700


On Aug 16, 2013, at 1:46 PM, cmaynard () wireshark org wrote:

http://anonsvn.wireshark.org/viewvc/viewvc.cgi?view=rev&revision=51395

User: cmaynard
Date: 2013/08/16 01:46 PM

Log:
Initialize val_len to avoid Clang warning: The right operand of '-' is a garbage value.  While in there, add some 
protection against tvb_length_remaining() possibly returning -1, or possibly being less than val_len.

Neither of those can happen - get_self_describing_var_len_val() would have thrown an exception if either

        1) there was no data left in the tvbuff

or

        2) there weren't enough bytes left in the tvbuff for the value.

The fix produces uninitialized-variable warnings about next_tvb.

(In addition, val_len should always be set; in the if statement in get_self_describing_var_len_val():

        the first code path is run if the high-order bit of the first octet isn't set;

        the second code path is run if the high-order bit is set but the next bit isn't set;

        the third code path is run if the high-order bit and the next bit are set but the third bit down isn't set;

        the fourth code path is run if all three of those bits are set;

so there's no other way out of the function, and *val_len will always be set.  Unfortunately, Clang isn't recognizing 
that (if it were recognizing it, it'd probably also not bother testing, in the fourth code path, whether all three of 
those bits are set, as the previous three tests failing ensure that they are).)
___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <wireshark-dev () wireshark org>
Archives:    http://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-request () wireshark org?subject=unsubscribe


Current thread: