https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6787
--- Comment #21 from Chris Maynard <christopher.maynard@xxxxxxxxx> 2012-07-31 14:05:38 PDT ---
(In reply to comment #20)
> Looking at packet-mpls.c (which calls this dissector), I suspect there should
> be some code to determine if there's any more to dissect after
>
> while(tvb_length_remaining(tvb) {
> ...
> if(...)
> break;
> }
>
> <test for data remaining ? >
>
> <continue dissecting>
I know this is only pseudo-code, but ... tvb_length_remaining() can return -1
if the offset is out of bounds. Also, as pointed out by Guy several years ago
(See http://www.ethereal.com/lists/ethereal-dev/200602/msg00363.html), in most
cases tvb_reported_length_remaining() should be used, not
tvb_length_remaining(). I'm not certain that would be the case here, but I
presume so. So, I suspect the above pseudo-code be written more like this:
while(tvb_reported_length_remaining(tvb, offset) > 0) {
...
if(...)
break;
}
Sadly, when I ran a quick search not too long ago, I counted 1599 occurrences
of tvb_length_remaining() vs. only 1022 occurrences of
tvb_reported_length_remaining(). I'm willing to bet that:
1) In many case, there's no need to use either of them at all.
2) Of the valid cases for using them that remain, many of the
tvb_length_remaining()'s should probably be converted to
tvb_reported_length_remaining().
Figuring out which are needed and which are not, as well as which should be
converted, doesn't sound like a particularly fun task though.
--
Configure bugmail: https://bugs.wireshark.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all bug changes.