[libxml2] Add regexp regression tests



commit 6b4717d61ddd8499872ff7249b6712732c8b11cb
Author: David Kilzer <ddkilzer apple com>
Date:   Mon Jul 6 12:36:27 2020 +0200

    Add regexp regression tests
    
    - Bug 757711: heap-buffer-overflow in xmlFAParsePosCharGroup
      <https://bugzilla.gnome.org/show_bug.cgi?id=757711>
    - Bug 783015 - Integer-overflow in xmlFAParseQuantExact
      <https://bugzilla.gnome.org/show_bug.cgi?id=783015>
    
    (Regexptests): Add support for checking stderr output when
    running regexp tests.  This makes it possible to check in test
    cases that fail and not see false-positive error output when
    running the tests.  Unlike other libxml2 test suites, if there
    is no stderr output, no *.err file needs to be created.

 Makefile.am                 | 12 +++++++-----
 result/regexp/bug757711     |  2 ++
 result/regexp/bug757711.err |  2 ++
 result/regexp/bug783015     |  4 ++++
 result/regexp/bug783015.err |  1 +
 test/regexp/bug757711       |  1 +
 test/regexp/bug783015       |  4 ++++
 7 files changed, 21 insertions(+), 5 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 2a9d4709..76a834ef 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -907,14 +907,16 @@ Regexptests: testRegexp$(EXEEXT)
          if [ ! -d $$i ] ; then \
          if [ ! -f $(srcdir)/result/regexp/$$name ] ; then \
              echo New test file $$name ; \
-             $(CHECKER) $(top_builddir)/testRegexp -i $$i > $(srcdir)/result/regexp/$$name; \
+             $(CHECKER) $(top_builddir)/testRegexp -i $$i > $(srcdir)/result/regexp/$$name 2> 
$(srcdir)/result/regexp/$$name.err ; \
+             if [ ! -s "$(srcdir)/result/regexp/$$name.err" ] ; then rm $(srcdir)/result/regexp/$$name.err; 
fi ; \
              grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
          else \
-             log=`$(CHECKER) $(top_builddir)/testRegexp -i $$i 2>&1 > result.$$name ; \
+             log=`$(CHECKER) $(top_builddir)/testRegexp -i $$i > result.$$name 2> error.$$name ; \
              grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
-             diff $(srcdir)/result/regexp/$$name result.$$name` ; \
-             if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
-             rm result.$$name ; \
+             diff $(srcdir)/result/regexp/$$name result.$$name ; \
+             if [ -s "$(srcdir)/result/regexp/$$name.err" -o -s "error.$$name" ] ; then diff 
$(srcdir)/result/regexp/$$name.err error.$$name ; fi` ; \
+             if [ -n "$$log" ] ; then echo $$name result ; echo $$log ; fi ; \
+             rm result.$$name error.$$name ; \
          fi ; fi ; done)
 
 # Disabled for now
diff --git a/result/regexp/bug757711 b/result/regexp/bug757711
new file mode 100644
index 00000000..0991e4e2
--- /dev/null
+++ b/result/regexp/bug757711
@@ -0,0 +1,2 @@
+Regexp: [;^((-
+   failed to compile
diff --git a/result/regexp/bug757711.err b/result/regexp/bug757711.err
new file mode 100644
index 00000000..f1cae806
--- /dev/null
+++ b/result/regexp/bug757711.err
@@ -0,0 +1,2 @@
+regexp error : failed to compile: Expecting the end of a char range
+regexp error : failed to compile: xmlFAParseCharClass: ']' expected
diff --git a/result/regexp/bug783015 b/result/regexp/bug783015
new file mode 100644
index 00000000..653f6f09
--- /dev/null
+++ b/result/regexp/bug783015
@@ -0,0 +1,4 @@
+Regexp: .{2147483647}
+input: Fail
+Regexp: .{2147483648}
+   failed to compile
diff --git a/result/regexp/bug783015.err b/result/regexp/bug783015.err
new file mode 100644
index 00000000..a00edc98
--- /dev/null
+++ b/result/regexp/bug783015.err
@@ -0,0 +1 @@
+regexp error : failed to compile: Improper quantifier
diff --git a/test/regexp/bug757711 b/test/regexp/bug757711
new file mode 100644
index 00000000..29098354
--- /dev/null
+++ b/test/regexp/bug757711
@@ -0,0 +1 @@
+=>[;^((-
diff --git a/test/regexp/bug783015 b/test/regexp/bug783015
new file mode 100644
index 00000000..5c91a0f1
--- /dev/null
+++ b/test/regexp/bug783015
@@ -0,0 +1,4 @@
+# This assumes 32-bit ints.
+=>.{2147483647}
+input
+=>.{2147483648}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]