Wireshark-dev: Re: [Wireshark-dev] [Wireshark-commits] rev 45462: /trunk/epan/dissectors/ /trun
From: Guy Harris <guy@xxxxxxxxxxxx>
Date: Wed, 10 Oct 2012 22:27:23 -0700
On Oct 10, 2012, at 8:55 PM, wmeier@xxxxxxxxxxxxx wrote:

> http://anonsvn.wireshark.org/viewvc/viewvc.cgi?view=rev&revision=45462
> 
> User: wmeier
> Date: 2012/10/10 08:55 PM
> 
> Log:
> Change 'for (i=1; i<=n;...' to 'for (i=0; i<n; ...)'
> 
> Done on general principles altho none of the cases
> changed would have actually resulted in an infinite
> loop because a Bounds error would eventually occur.

Actually, this one:

    for(sid_number = 1; sid_number <= number_of_sids; sid_number++) {
      proto_tree_add_item(parameter_tree, hf_stream_reset_sid, parameter_tvb, sid_offset, SID_LENGTH, ENC_BIG_ENDIAN);
      sid_offset += SID_LENGTH;
    }

could conceivably *not* cause a bounds error, as it looks as if it'd be executed even if parameter_tree is null, in which case the proto_tree_add_item() calls will just return without fetching anything from the tvbuff.  (That's why the buildbot bug I fixed with a similar change only showed up when I ran TShark *without* -V - *with* -v, proto_tree_add_item() actually fetched data from the tvbuff and threw a bounds error when it went past the end of the packet, but without it (and without any display/read filter or color filter or anything else that required building a protocol tree or even just fetching protocol field values), nothing was fetched and no exceptions were thrown.