aboutsummaryrefslogtreecommitdiffstats
path: root/packet-slimp3.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2002-02-02 02:59:23 +0000
committerGuy Harris <guy@alum.mit.edu>2002-02-02 02:59:23 +0000
commit6fd493715ed41cb4da95fdfc8a4eca68c3fc6d4e (patch)
treef8be12fe659bafdb3e06688106af4394b78a0203 /packet-slimp3.c
parent70ae5ab15e827abc2f351fee7e7ff9f9fd747d55 (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.) svn path=/trunk/; revision=4672
Diffstat (limited to 'packet-slimp3.c')
-rw-r--r--packet-slimp3.c34
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;