From d97f729ae3156124f3ebafc77720c9c734a738f5 Mon Sep 17 00:00:00 2001 From: Alexis La Goutte Date: Mon, 27 Feb 2012 16:43:18 +0000 Subject: From Alex Rodikov via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6871 TPNCP (proprietary Audiocodes) protocol dessector - wrong guint8 value presentation The presentation of unsigned 8-bit integer is wrong. The (signed) gint8 is used which is displayed as unsigned integer (by proto_tree_add_uint) afterwards. That causes wrong presentation of valus which bigger than 127. Solution: New guint8 is introduced to present unsigned 8 bit integer value. svn path=/trunk/; revision=41209 --- epan/dissectors/packet-tpncp.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'epan/dissectors/packet-tpncp.c') diff --git a/epan/dissectors/packet-tpncp.c b/epan/dissectors/packet-tpncp.c index f3d88fa72a..8e77c3b471 100644 --- a/epan/dissectors/packet-tpncp.c +++ b/epan/dissectors/packet-tpncp.c @@ -139,6 +139,7 @@ static void dissect_tpncp_data(gint data_id, tvbuff_t *tvb, proto_item *item, gint16 g_short; guint16 g_ushort; gint8 g_char; + guint8 g_uchar; gchar *g_str = NULL; gint g_str_len, counter, bitshift, bitmask; tpncp_data_field_info *current_tpncp_data_field_info = NULL; @@ -161,21 +162,23 @@ static void dissect_tpncp_data(gint data_id, tvbuff_t *tvb, proto_item *item, g_free(g_str); } else { /* add single char */ - g_char = tvb_get_guint8(tvb, *offset); + g_uchar = tvb_get_guint8(tvb, *offset); /* bitfields */ if (current_tpncp_data_field_info->tpncp_data_field_size != 8) { for (counter = 0, bitmask = 0x0, bitshift = bitindex; counter < current_tpncp_data_field_info->tpncp_data_field_size; counter++) bitmask |= bits[bitindex++]; /* Bitmask of interesting bits. */ - g_char &= bitmask; - g_char >>= bitshift; + g_uchar &= bitmask; + g_uchar >>= bitshift; } - if (current_tpncp_data_field_info->tpncp_data_field_sign) { + if (current_tpncp_data_field_info->tpncp_data_field_sign || current_tpncp_data_field_info->tpncp_data_field_size != 8) { proto_tree_add_uint(ltree, current_tpncp_data_field_info->tpncp_data_field_descr, - tvb, *offset, 1, g_char); + tvb, *offset, 1, g_uchar); } else { + /* signed*/ + g_char = (gint8)g_uchar; proto_tree_add_int(ltree, current_tpncp_data_field_info->tpncp_data_field_descr, tvb, *offset, 1, g_char); } -- cgit v1.2.3