From Alex Rodikov via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6871
authoralagoutte <alagoutte@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 27 Feb 2012 16:43:18 +0000 (16:43 +0000)
committeralagoutte <alagoutte@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 27 Feb 2012 16:43:18 +0000 (16:43 +0000)
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.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@41209 f5534014-38df-0310-8fa8-9805f1628bb7

epan/dissectors/packet-tpncp.c

index f3d88fa..8e77c3b 100644 (file)
@@ -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);
                     }