Blame SOURCES/wireshark-0016-CVE-19622.patch

164878
diff --git a/epan/dissectors/packet-mmse.c b/epan/dissectors/packet-mmse.c
164878
index ffb4faa003..1e3d13abeb 100644
164878
--- a/epan/dissectors/packet-mmse.c
164878
+++ b/epan/dissectors/packet-mmse.c
164878
@@ -487,6 +487,12 @@ get_value_length(tvbuff_t *tvb, guint offset, guint *byte_count, packet_info *pi
164878
         field = tvb_get_guintvar(tvb, offset, byte_count, pinfo, &ei_mmse_oversized_uintvar);
164878
         (*byte_count)++;
164878
     }
164878
+
164878
+    /* The packet says there are this many bytes; ensure they're there.
164878
+     * We do this here because several callers do math on the length we
164878
+     * return here and may not catch an overflow.
164878
+     */
164878
+    tvb_ensure_bytes_exist(tvb, offset, field);
164878
     return field;
164878
 }
164878
 
164878
@@ -689,7 +695,7 @@ static void
164878
 dissect_mmse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint8 pdut,
164878
         const char *message_type)
164878
 {
164878
-    guint        offset;
164878
+    guint        offset, old_offset;
164878
     guint8       field = 0;
164878
     const char   *strval;
164878
     guint        length;
164878
@@ -711,6 +717,7 @@ dissect_mmse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint8 pdut,
164878
     proto_tree_add_uint(mmse_tree, hf_mmse_message_type, tvb, 0, 2, pdut);
164878
 
164878
     offset = 2;                 /* Skip Message-Type    */
164878
+    old_offset = 1;
164878
 
164878
     /*
164878
      * Cycle through MMS-headers
164878
@@ -1209,6 +1216,11 @@ dissect_mmse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint8 pdut,
164878
                 break;
164878
         }
164878
         DebugLog(("\tEnd(case)\n"));
164878
+
164878
+        if (offset <= old_offset) {
164878
+            REPORT_DISSECTOR_BUG("Offset isn't increasing (offset=%u, old offset=%u)", offset, old_offset);
164878
+        }
164878
+        old_offset = offset;
164878
     }
164878
 
164878
     DebugLog(("\tEnd(switch)\n"));