Blame SOURCES/wireshark-1.10.14-CVE-2015-6248.patch

affdba
diff --git a/epan/proto.c b/epan/proto.c
affdba
index 004acb0..bf98a27 100644
affdba
--- a/epan/proto.c
affdba
+++ b/epan/proto.c
affdba
@@ -1758,6 +1758,31 @@ proto_tree_new_item(field_info *new_fi, proto_tree *tree,
affdba
 	return pi;
affdba
 }
affdba
 
affdba
+
affdba
+/*
affdba
+ * Validates that field length bytes are available starting from
affdba
+ * start (pos/neg). Throws an exception if they aren't.
affdba
+ */
affdba
+static void
affdba
+test_length(header_field_info *hfinfo, tvbuff_t *tvb,
affdba
+	    gint start, gint length)
affdba
+{
affdba
+	gint size = length;
affdba
+
affdba
+	if (!tvb)
affdba
+		return;
affdba
+
affdba
+	if (hfinfo->type == FT_STRINGZ) {
affdba
+		/* If we're fetching until the end of the TVB, only validate
affdba
+		 * that the offset is within range.
affdba
+		 */
affdba
+		if (length == -1)
affdba
+			size = 0;
affdba
+	}
affdba
+
affdba
+	tvb_ensure_bytes_exist(tvb, start, size);
affdba
+}
affdba
+
affdba
 /* Gets data from tvbuff, adds it to proto_tree, increments offset,
affdba
    and returns proto_item* */
affdba
 proto_item *
affdba
@@ -1786,6 +1811,8 @@ ptvcursor_add(ptvcursor_t *ptvc, int hfindex, gint length,
affdba
 		ptvc->offset += n;
affdba
 	}
affdba
 
affdba
+	test_length(hfinfo, ptvc->tvb, offset, item_length);
affdba
+
affdba
 	/* Coast clear. Try and fake it */
affdba
 	TRY_TO_FAKE_THIS_ITEM(ptvc->tree, hfindex, hfinfo);
affdba
 
affdba
@@ -1795,45 +1822,6 @@ ptvcursor_add(ptvcursor_t *ptvc, int hfindex, gint length,
affdba
 		offset, length, encoding);
affdba
 }
affdba
 
affdba
-/*
affdba
- * Validates that field length bytes are available starting from
affdba
- * start (pos/neg). Throws an exception if they aren't.
affdba
- */
affdba
-static void
affdba
-test_length(header_field_info *hfinfo, proto_tree *tree, tvbuff_t *tvb,
affdba
-	    gint start, gint length, const guint encoding)
affdba
-{
affdba
-	gint size = length;
affdba
-
affdba
-	if (!tvb)
affdba
-		return;
affdba
-
affdba
-	if (hfinfo->type == FT_UINT_BYTES || hfinfo->type == FT_UINT_STRING) {
affdba
-		guint32 n;
affdba
-
affdba
-		n = get_uint_value(tree, tvb, start, length, encoding);
affdba
-		if (n > size + n) {
affdba
-			/* If n > size + n then we have an integer overflow, so
affdba
-			 * set size to -1, which will force the
affdba
-			 * tvb_ensure_bytes_exist call below to throw a
affdba
-			 * ReportedBoundsError
affdba
-			 */
affdba
-			size = -1;
affdba
-		}
affdba
-		else {
affdba
-			size += n;
affdba
-		}
affdba
-	} else if (hfinfo->type == FT_STRINGZ) {
affdba
-		/* If we're fetching until the end of the TVB, only validate
affdba
-		 * that the offset is within range.
affdba
-		 */
affdba
-		if (length == -1)
affdba
-			size = 0;
affdba
-	}
affdba
-
affdba
-	tvb_ensure_bytes_exist(tvb, start, size);
affdba
-}
affdba
-
affdba
 /* Add an item to a proto_tree, using the text label registered to that item;
affdba
    the item is extracted from the tvbuff handed to it. */
affdba
 proto_item *
affdba
@@ -1845,7 +1833,7 @@ proto_tree_add_item(proto_tree *tree, const int hfindex, tvbuff_t *tvb,
affdba
 	gint		  item_length;
affdba
 
affdba
 	hfinfo = get_hfi_and_length(hfindex, tvb, start, &length, &item_length);
affdba
-	test_length(hfinfo, tree, tvb, start, item_length, encoding);
affdba
+	test_length(hfinfo, tvb, start, item_length);
affdba
 
affdba
 	TRY_TO_FAKE_THIS_ITEM(tree, hfindex, hfinfo);
affdba
 
affdba
@@ -7540,7 +7528,7 @@ proto_tree_add_bits_item(proto_tree *tree, const int hf_index, tvbuff_t *tvb,
affdba
 
affdba
 	octet_length = (no_of_bits + 7) >> 3;
affdba
 	octet_offset = bit_offset >> 3;
affdba
-	test_length(hfinfo, tree, tvb, octet_offset, octet_length, encoding);
affdba
+	test_length(hfinfo, tvb, octet_offset, octet_length);
affdba
 
affdba
 	/* Yes, we try to fake this item again in proto_tree_add_bits_ret_val()
affdba
 	 * but only after doing a bunch more work (which we can, in the common