diff options
author | Guy Harris <guy@alum.mit.edu> | 2018-04-09 23:06:47 -0700 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2018-04-10 14:55:45 +0000 |
commit | c7970d9356a494d847101c2bd92e4ca97a7d3d58 (patch) | |
tree | e894b469ecc2c26563fbce3a9512af9bad66c594 /epan/dissectors/packet-amqp.c | |
parent | 2cb93e2121eea20c1e443558d7175f1cab8e1f70 (diff) |
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 <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-amqp.c')
-rw-r--r-- | epan/dissectors/packet-amqp.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/epan/dissectors/packet-amqp.c b/epan/dissectors/packet-amqp.c index 255baba26b..a627da165c 100644 --- a/epan/dissectors/packet-amqp.c +++ b/epan/dissectors/packet-amqp.c @@ -2408,7 +2408,7 @@ dissect_amqp_0_9_field_value(tvbuff_t *tvb, packet_info *pinfo, int offset, guin if (length < 4) return 0; /* too short */ value = wmem_strdup_printf(wmem_packet_scope(), "%" G_GINT32_MODIFIER "i", - (gint32)tvb_get_ntohl(tvb, offset)); + tvb_get_ntohil(tvb, offset)); offset += 4; break; case 'D': @@ -2474,7 +2474,7 @@ dissect_amqp_0_9_field_value(tvbuff_t *tvb, packet_info *pinfo, int offset, guin if (length < 1) return 0; /* too short */ value = wmem_strdup_printf(wmem_packet_scope(), "%d", - (gint8)tvb_get_guint8(tvb, offset)); + tvb_get_gint8(tvb, offset)); offset += 1; break; case 'B': /* unsigned 8-bit */ @@ -2490,7 +2490,7 @@ dissect_amqp_0_9_field_value(tvbuff_t *tvb, packet_info *pinfo, int offset, guin if (length < 2) return 0; /* too short */ value = wmem_strdup_printf(wmem_packet_scope(), "%" G_GINT16_MODIFIER "i", - (gint16)tvb_get_ntohs(tvb, offset)); + tvb_get_ntohis(tvb, offset)); offset += 2; break; case 'u': /* unsigned 16-bit */ @@ -2514,7 +2514,7 @@ dissect_amqp_0_9_field_value(tvbuff_t *tvb, packet_info *pinfo, int offset, guin if (length < 8) return 0; /* too short */ value = wmem_strdup_printf(wmem_packet_scope(), "%" G_GINT64_MODIFIER "i", - (gint64)tvb_get_ntoh64(tvb, offset)); + tvb_get_ntohi64(tvb, offset)); offset += 8; break; case 'f': /* 32-bit float */ @@ -10348,13 +10348,13 @@ format_amqp_1_0_int(tvbuff_t *tvb, gint64 val; if (length == 1) - val = (gint8)tvb_get_guint8(tvb, offset); + val = tvb_get_gint8(tvb, offset); else if (length == 2) - val = (gint16)tvb_get_ntohs(tvb, offset); + val = tvb_get_ntohis(tvb, offset); else if (length == 4) - val = (gint32)tvb_get_ntohl(tvb, offset); + val = tvb_get_ntohil(tvb, offset); else if (length == 8) - val = (gint64)tvb_get_ntoh64(tvb, offset); + val = tvb_get_ntohi64(tvb, offset); else { *value = wmem_strdup_printf(wmem_packet_scope(), "Invalid int length %d!", length); return length; @@ -10529,11 +10529,11 @@ format_amqp_0_10_int(tvbuff_t *tvb, int val; if (length == 1) - val = (gint8)tvb_get_guint8(tvb, offset); + val = tvb_get_gint8(tvb, offset); else if (length == 2) - val = (gint16)tvb_get_ntohs(tvb, offset); + val = tvb_get_ntohis(tvb, offset); else if (length == 4) - val = (gint32)tvb_get_ntohl(tvb, offset); + val = tvb_get_ntohil(tvb, offset); else { *value = wmem_strdup_printf(wmem_packet_scope(), "Invalid int length %d!", length); return length; |