From c7970d9356a494d847101c2bd92e4ca97a7d3d58 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Mon, 9 Apr 2018 23:06:47 -0700 Subject: Add, and use, "fetch signed value" for lengths < 40 bits. Add 8-bit, 16-bit, 24-bit, and 32-bit "fetch signed value" routines, and use them rather than casting the result of the 8/16/24/32-bit "fetch unsigned value" routines to a signed type (which, BTW, isn't sufficient for 24-bit values, so this appears to fix a bug in epan/dissectors/packet-zbee-zcl.c). Use numbers rather than sizeof()s in various tvb_get_ routines. Change-Id: I0e48a57fac9f70fe42de815c3fa915f1592548bd Reviewed-on: https://code.wireshark.org/review/26844 Petri-Dish: Guy Harris Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- epan/dissectors/packet-ppi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'epan/dissectors/packet-ppi.c') diff --git a/epan/dissectors/packet-ppi.c b/epan/dissectors/packet-ppi.c index ac5ee97298..259d5621bd 100644 --- a/epan/dissectors/packet-ppi.c +++ b/epan/dissectors/packet-ppi.c @@ -570,7 +570,7 @@ dissect_80211_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int of } ptvcursor_add(csr, hf_80211_common_fhss_pattern, 1, ENC_LITTLE_ENDIAN); - dbm_value = (gint8) tvb_get_guint8(tvb, ptvcursor_current_offset(csr)); + dbm_value = tvb_get_gint8(tvb, ptvcursor_current_offset(csr)); if (dbm_value != -128 && dbm_value != 0) { /* * XXX - the spec says -128 is invalid, presumably meaning "use @@ -584,7 +584,7 @@ dissect_80211_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int of } ptvcursor_add_invalid_check(csr, hf_80211_common_dbm_antsignal, 1, 0x80); /* -128 */ - dbm_value = (gint8) tvb_get_guint8(tvb, ptvcursor_current_offset(csr)); + dbm_value = tvb_get_gint8(tvb, ptvcursor_current_offset(csr)); if (dbm_value != -128 && dbm_value != 0) { /* * XXX - the spec says -128 is invalid, presumably meaning "use -- cgit v1.2.3