0003-Schematron-Fix-null-pointer-dereference-leading-to-D.patch 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. From 4df1c80c4edc51ecb9f2f574203128a06fd31406 Mon Sep 17 00:00:00 2001
  2. From: Michael Mann <mmann78@netscape.net>
  3. Date: Sat, 21 Jun 2025 12:11:30 -0400
  4. Subject: [PATCH] Schematron: Fix null pointer dereference leading to DoS
  5. (CVE-2025-49795)
  6. Fixes #932
  7. Upstream: https://gitlab.gnome.org/GNOME/libxml2/-/commit/499bcb78ab389f60c2fd634ce410d4bb85c18765
  8. CVE: CVE-2025-49795
  9. Signed-off-by: Tim Soubry <tim.soubry@mind.be>
  10. ---
  11. result/schematron/zvon16_0.err | 1 +
  12. schematron.c | 2 ++
  13. test/schematron/zvon16.sct | 7 +++++++
  14. test/schematron/zvon16_0.xml | 5 +++++
  15. 4 files changed, 15 insertions(+)
  16. create mode 100644 result/schematron/zvon16_0.err
  17. create mode 100644 test/schematron/zvon16.sct
  18. create mode 100644 test/schematron/zvon16_0.xml
  19. diff --git a/result/schematron/zvon16_0.err b/result/schematron/zvon16_0.err
  20. new file mode 100644
  21. index 00000000..465cf2eb
  22. --- /dev/null
  23. +++ b/result/schematron/zvon16_0.err
  24. @@ -0,0 +1 @@
  25. +xmlSchematronParse: could not load './test/schematron/zvon16.sct'
  26. \ No newline at end of file
  27. diff --git a/schematron.c b/schematron.c
  28. index 426300c8..b51b20e1 100644
  29. --- a/schematron.c
  30. +++ b/schematron.c
  31. @@ -1509,6 +1509,8 @@ xmlSchematronFormatReport(xmlSchematronValidCtxtPtr ctxt,
  32. select = xmlGetNoNsProp(child, BAD_CAST "select");
  33. comp = xmlXPathCtxtCompile(ctxt->xctxt, select);
  34. eval = xmlXPathCompiledEval(comp, ctxt->xctxt);
  35. + if (eval == NULL)
  36. + return ret;
  37. switch (eval->type) {
  38. case XPATH_NODESET: {
  39. diff --git a/test/schematron/zvon16.sct b/test/schematron/zvon16.sct
  40. new file mode 100644
  41. index 00000000..4d24c054
  42. --- /dev/null
  43. +++ b/test/schematron/zvon16.sct
  44. @@ -0,0 +1,7 @@
  45. +<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron"
  46. + <sch:pattern id="TestPattern">
  47. + <sch:rule context="book">
  48. + <sch:report test="not(@available)">Book <sch:value-of select="falae()"/> test</sch:report>
  49. + </sch:rule>
  50. + </sch:pattern>
  51. +</sch:schema>
  52. diff --git a/test/schematron/zvon16_0.xml b/test/schematron/zvon16_0.xml
  53. new file mode 100644
  54. index 00000000..551e2d65
  55. --- /dev/null
  56. +++ b/test/schematron/zvon16_0.xml
  57. @@ -0,0 +1,5 @@
  58. +<library>
  59. + <book title="Test Book" id="bk101">
  60. + <author>Test Author</author>
  61. + </book>
  62. +</library>
  63. --
  64. 2.39.5