You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.8 KiB

  1. From a436374994c47b12d5de1b8b1d191a098fa23594 Mon Sep 17 00:00:00 2001
  2. From: Nick Wellnhofer <wellnhofer@aevum.de>
  3. Date: Mon, 30 Jul 2018 12:54:38 +0200
  4. Subject: [PATCH 12/13] Fix nullptr deref with XPath logic ops
  5. If the XPath stack is corrupted, for example by a misbehaving extension
  6. function, the "and" and "or" XPath operators could dereference NULL
  7. pointers. Check that the XPath stack isn't empty and optimize the
  8. logic operators slightly.
  9. Closes: https://gitlab.gnome.org/GNOME/libxml2/issues/5
  10. Also see
  11. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=901817
  12. https://bugzilla.redhat.com/show_bug.cgi?id=1595985
  13. This is CVE-2018-14404.
  14. Thanks to Guy Inbar for the report.
  15. ---
  16. xpath.c | 10 ++++------
  17. 1 file changed, 4 insertions(+), 6 deletions(-)
  18. diff --git a/xpath.c b/xpath.c
  19. index 3fae0bf4..5e3bb9ff 100644
  20. --- a/xpath.c
  21. +++ b/xpath.c
  22. @@ -13297,9 +13297,8 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
  23. return(0);
  24. }
  25. xmlXPathBooleanFunction(ctxt, 1);
  26. - arg1 = valuePop(ctxt);
  27. - arg1->boolval &= arg2->boolval;
  28. - valuePush(ctxt, arg1);
  29. + if (ctxt->value != NULL)
  30. + ctxt->value->boolval &= arg2->boolval;
  31. xmlXPathReleaseObject(ctxt->context, arg2);
  32. return (total);
  33. case XPATH_OP_OR:
  34. @@ -13323,9 +13322,8 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
  35. return(0);
  36. }
  37. xmlXPathBooleanFunction(ctxt, 1);
  38. - arg1 = valuePop(ctxt);
  39. - arg1->boolval |= arg2->boolval;
  40. - valuePush(ctxt, arg1);
  41. + if (ctxt->value != NULL)
  42. + ctxt->value->boolval |= arg2->boolval;
  43. xmlXPathReleaseObject(ctxt->context, arg2);
  44. return (total);
  45. case XPATH_OP_EQUAL:
  46. --
  47. 2.18.0