From Pascal Quantin:
authormartinm <martinm@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 13 Nov 2010 15:32:29 +0000 (15:32 +0000)
committermartinm <martinm@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 13 Nov 2010 15:32:29 +0000 (15:32 +0000)
- Set a default RNTI value for each type, in case optional RNTI value isn't supplied.
- Improve range checking of given type against acceptable range of values
- fix misplaced return (this fixed bug 5392)

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

epan/dissectors/packet-mac-lte.c

index 7e27488b5c416eb819e5190e0323918bf483fc1b..fdd091b6334d5cde5b3b6c02e674ca17353c2610 100644 (file)
@@ -882,6 +882,23 @@ static gboolean dissect_mac_lte_heur(tvbuff_t *tvb, packet_info *pinfo,
 
     p_mac_lte_info->rntiType = tvb_get_guint8(tvb, offset++);
 
+    /* Initialize RNTI with a default value in case optional field is not present */
+       switch (p_mac_lte_info->rntiType) {
+        case P_RNTI:
+            p_mac_lte_info->rnti = 0xFFFE;
+            break;
+        case SI_RNTI:
+            p_mac_lte_info->rnti = 0xFFFF;
+            break;
+        case RA_RNTI:
+        case C_RNTI:
+        case SPS_RNTI:
+            p_mac_lte_info->rnti = 0x0001;
+            break;
+        default:
+            break;
+    }
+                       
     /* Read optional fields */
     while (tag != MAC_LTE_PAYLOAD_TAG) {
         /* Process next tag */
@@ -3028,14 +3045,23 @@ void dissect_mac_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
             }
             break;
         case RA_RNTI:
+            if ((p_mac_lte_info->rnti < 0x0001) || (p_mac_lte_info->rnti > 0x003C)) {
+                expert_add_info_format(pinfo, ti, PI_MALFORMED, PI_ERROR,
+                      "RA_RNTI indicated, but given value %u (0x%x)is out of range",
+                      p_mac_lte_info->rnti, p_mac_lte_info->rnti);
+                return;
+            }
+            break;
         case C_RNTI:
+        case SPS_RNTI:
             if ((p_mac_lte_info->rnti < 0x0001) || (p_mac_lte_info->rnti > 0xFFF3)) {
                 expert_add_info_format(pinfo, ti, PI_MALFORMED, PI_ERROR,
                       "%s indicated, but given value %u (0x%x)is out of range",
                       val_to_str_const(p_mac_lte_info->rntiType,  rnti_type_vals, "Unknown"),
                       p_mac_lte_info->rnti, p_mac_lte_info->rnti);
+                return;
             }
-            return;
+            break;
 
         default:
             break;