Blame SOURCES/0034-v2v-Add-bounds-check-to-Xml.xpathobj_node-function.patch

0d20ef
From 88927f4922aae25dda3a5cf42afada3edd8da0fc Mon Sep 17 00:00:00 2001
0d20ef
From: "Richard W.M. Jones" <rjones@redhat.com>
0d20ef
Date: Fri, 31 Oct 2014 15:57:45 +0000
0d20ef
Subject: [PATCH] v2v: Add bounds check to Xml.xpathobj_node function.
0d20ef
0d20ef
I accidentally called it with an out-of-bounds index, and it caused a
0d20ef
core dump.  Add a bounds check to stop this from happening in
0d20ef
production.
0d20ef
0d20ef
(cherry picked from commit 1470be7f3b36b9ba6862fd04aa66446e89b108a7)
0d20ef
---
0d20ef
 v2v/xml-c.c | 3 +++
0d20ef
 1 file changed, 3 insertions(+)
0d20ef
0d20ef
diff --git a/v2v/xml-c.c b/v2v/xml-c.c
0d20ef
index f26e362..0b619e5 100644
0d20ef
--- a/v2v/xml-c.c
0d20ef
+++ b/v2v/xml-c.c
0d20ef
@@ -197,6 +197,9 @@ v2v_xml_xpathobj_get_node_ptr (value xpathobjv, value iv)
0d20ef
   xmlXPathObjectPtr xpathobj = Xpathobj_val (xpathobjv);
0d20ef
   int i = Int_val (iv);
0d20ef
 
0d20ef
+  if (i < 0 || i >= xpathobj->nodesetval->nodeNr)
0d20ef
+    caml_invalid_argument ("get_node_ptr: node number out of range");
0d20ef
+
0d20ef
   /* Because xmlNodePtrs are owned by the document, we don't want to
0d20ef
    * wrap this up with a finalizer, so just pass the pointer straight
0d20ef
    * back to OCaml as a value.  OCaml will ignore it because it's
0d20ef
-- 
0d20ef
1.8.3.1
0d20ef