diff options
author | guy <guy@f5534014-38df-0310-8fa8-9805f1628bb7> | 2002-02-02 02:59:23 +0000 |
---|---|---|
committer | guy <guy@f5534014-38df-0310-8fa8-9805f1628bb7> | 2002-02-02 02:59:23 +0000 |
commit | 73c790f04a74dd0301a23b604c24f7622d6ff1a1 (patch) | |
tree | f8be12fe659bafdb3e06688106af4394b78a0203 /packet-slimp3.c | |
parent | b62a20c406a8a73d126c767dfb91254c31fd7408 (diff) |
Use "tvb_offset_exists()" rather than "tvb_length_remaining()" in a loop
scanning the tvbuff. Also use "tvb_offset_exists()" before accessing
the tvbuff in that loop; the loop is only building the Info column, so
it shouldn't throw an exception before building the list.
(XXX - it should arguably all be done in one loop, with the Info column
built on the fly.)
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@4672 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'packet-slimp3.c')
-rw-r--r-- | packet-slimp3.c | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/packet-slimp3.c b/packet-slimp3.c index ef38809b5a..c8fc22ff8c 100644 --- a/packet-slimp3.c +++ b/packet-slimp3.c @@ -6,7 +6,7 @@ * Adds support for the data packet protocol for the SliMP3 * See www.slimdevices.com for details. * - * $Id: packet-slimp3.c,v 1.3 2002/01/24 09:20:51 guy Exp $ + * $Id: packet-slimp3.c,v 1.4 2002/02/02 02:59:23 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -310,23 +310,33 @@ dissect_slimp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) if (check_col(pinfo->cinfo, COL_INFO)) { i1 = 18; addc_strp = addc_str; - while (i1 < tvb_length_remaining(tvb, offset)) { - switch(tvb_get_guint8(tvb, offset + i1)) { - case 0: *addc_strp++ = '.'; break; - case 2: *addc_strp++ = '|'; - if ((tvb_get_guint8(tvb, offset + i1 + 1) & 0xf0) == 0x30) i1+=2; + while (tvb_offset_exists(tvb, offset + i1)) { + switch (tvb_get_guint8(tvb, offset + i1)) { + + case 0: + *addc_strp++ = '.'; + break; + + case 2: + *addc_strp++ = '|'; + if (tvb_offset_exists(tvb, offset + i1 + 1) && + (tvb_get_guint8(tvb, offset + i1 + 1) & 0xf0) == 0x30) + i1 += 2; break; + case 3: - if (addc_strp==addc_str || - *(addc_strp-1)!=' ' || - tvb_get_guint8(tvb, offset + i1 + 1) != ' ') - *addc_strp++ = tvb_get_guint8(tvb, offset + i1 + 1); + if (tvb_offset_exists(tvb, offset + i1 + 1)) { + if (addc_strp == addc_str || + *(addc_strp-1) != ' ' || + tvb_get_guint8(tvb, offset + i1 + 1) != ' ') + *addc_strp++ = tvb_get_guint8(tvb, offset + i1 + 1); + } } - i1+=2; + i1 += 2; } *addc_strp = 0; if (addc_strp - addc_str > 0) - col_append_fstr(pinfo->cinfo, COL_INFO, ", %s", addc_str); + col_append_fstr(pinfo->cinfo, COL_INFO, ", %s", addc_str); } break; |