1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-03-24 06:50:08 +03:00

Fix NULL pointer deref in XPointer range-to

- Check for errors after evaluating first operand.
- Add sanity check for empty stack.

Found with afl-fuzz.
This commit is contained in:
Nick Wellnhofer 2016-06-25 12:35:50 +02:00
parent 1fc55ca72b
commit d8083bf779
3 changed files with 11 additions and 1 deletions

View File

@ -0,0 +1,4 @@
========================
Expression: xpointer(non-existing-fn()/range-to(id('chapter2')))
Object is empty (NULL)

1
test/XPath/xptr/viderror Normal file
View File

@ -0,0 +1 @@
xpointer(non-existing-fn()/range-to(id('chapter2')))

View File

@ -14005,9 +14005,14 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
xmlNodeSetPtr oldset;
int i, j;
if (op->ch1 != -1)
if (op->ch1 != -1) {
total +=
xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
CHECK_ERROR0;
}
if (ctxt->value == NULL) {
XP_ERROR0(XPATH_INVALID_OPERAND);
}
if (op->ch2 == -1)
return (total);