diff options
Diffstat (limited to 'meta/recipes-core/libxml/libxml2')
10 files changed, 1490 insertions, 0 deletions
diff --git a/meta/recipes-core/libxml/libxml2/0001-CVE-2015-1819-Enforce-the-reader-to-run-in-constant-.patch b/meta/recipes-core/libxml/libxml2/0001-CVE-2015-1819-Enforce-the-reader-to-run-in-constant-.patch new file mode 100644 index 0000000000..96d58f9dd6 --- /dev/null +++ b/meta/recipes-core/libxml/libxml2/0001-CVE-2015-1819-Enforce-the-reader-to-run-in-constant-.patch | |||
@@ -0,0 +1,181 @@ | |||
1 | From 213f1fe0d76d30eaed6e5853057defc43e6df2c9 Mon Sep 17 00:00:00 2001 | ||
2 | From: Daniel Veillard <veillard@redhat.com> | ||
3 | Date: Tue, 14 Apr 2015 17:41:48 +0800 | ||
4 | Subject: [PATCH] CVE-2015-1819 Enforce the reader to run in constant memory | ||
5 | |||
6 | One of the operation on the reader could resolve entities | ||
7 | leading to the classic expansion issue. Make sure the | ||
8 | buffer used for xmlreader operation is bounded. | ||
9 | Introduce a new allocation type for the buffers for this effect. | ||
10 | |||
11 | Upstream-Status: Backport | ||
12 | |||
13 | Signed-off-by: Yue Tao <Yue.Tao@windriver.com> | ||
14 | Signed-off-by: Wenzong Fan <wenzong.fan@windriver.com> | ||
15 | --- | ||
16 | buf.c | 43 ++++++++++++++++++++++++++++++++++++++++++- | ||
17 | include/libxml/tree.h | 3 ++- | ||
18 | xmlreader.c | 20 +++++++++++++++++++- | ||
19 | 3 files changed, 63 insertions(+), 3 deletions(-) | ||
20 | |||
21 | diff --git a/buf.c b/buf.c | ||
22 | index 6efc7b6..07922ff 100644 | ||
23 | --- a/buf.c | ||
24 | +++ b/buf.c | ||
25 | @@ -27,6 +27,7 @@ | ||
26 | #include <libxml/tree.h> | ||
27 | #include <libxml/globals.h> | ||
28 | #include <libxml/tree.h> | ||
29 | +#include <libxml/parserInternals.h> /* for XML_MAX_TEXT_LENGTH */ | ||
30 | #include "buf.h" | ||
31 | |||
32 | #define WITH_BUFFER_COMPAT | ||
33 | @@ -299,7 +300,8 @@ xmlBufSetAllocationScheme(xmlBufPtr buf, | ||
34 | if ((scheme == XML_BUFFER_ALLOC_DOUBLEIT) || | ||
35 | (scheme == XML_BUFFER_ALLOC_EXACT) || | ||
36 | (scheme == XML_BUFFER_ALLOC_HYBRID) || | ||
37 | - (scheme == XML_BUFFER_ALLOC_IMMUTABLE)) { | ||
38 | + (scheme == XML_BUFFER_ALLOC_IMMUTABLE) || | ||
39 | + (scheme == XML_BUFFER_ALLOC_BOUNDED)) { | ||
40 | buf->alloc = scheme; | ||
41 | if (buf->buffer) | ||
42 | buf->buffer->alloc = scheme; | ||
43 | @@ -458,6 +460,18 @@ xmlBufGrowInternal(xmlBufPtr buf, size_t len) { | ||
44 | size = buf->use + len + 100; | ||
45 | #endif | ||
46 | |||
47 | + if (buf->alloc == XML_BUFFER_ALLOC_BOUNDED) { | ||
48 | + /* | ||
49 | + * Used to provide parsing limits | ||
50 | + */ | ||
51 | + if ((buf->use + len >= XML_MAX_TEXT_LENGTH) || | ||
52 | + (buf->size >= XML_MAX_TEXT_LENGTH)) { | ||
53 | + xmlBufMemoryError(buf, "buffer error: text too long\n"); | ||
54 | + return(0); | ||
55 | + } | ||
56 | + if (size >= XML_MAX_TEXT_LENGTH) | ||
57 | + size = XML_MAX_TEXT_LENGTH; | ||
58 | + } | ||
59 | if ((buf->alloc == XML_BUFFER_ALLOC_IO) && (buf->contentIO != NULL)) { | ||
60 | size_t start_buf = buf->content - buf->contentIO; | ||
61 | |||
62 | @@ -739,6 +753,15 @@ xmlBufResize(xmlBufPtr buf, size_t size) | ||
63 | CHECK_COMPAT(buf) | ||
64 | |||
65 | if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return(0); | ||
66 | + if (buf->alloc == XML_BUFFER_ALLOC_BOUNDED) { | ||
67 | + /* | ||
68 | + * Used to provide parsing limits | ||
69 | + */ | ||
70 | + if (size >= XML_MAX_TEXT_LENGTH) { | ||
71 | + xmlBufMemoryError(buf, "buffer error: text too long\n"); | ||
72 | + return(0); | ||
73 | + } | ||
74 | + } | ||
75 | |||
76 | /* Don't resize if we don't have to */ | ||
77 | if (size < buf->size) | ||
78 | @@ -867,6 +890,15 @@ xmlBufAdd(xmlBufPtr buf, const xmlChar *str, int len) { | ||
79 | |||
80 | needSize = buf->use + len + 2; | ||
81 | if (needSize > buf->size){ | ||
82 | + if (buf->alloc == XML_BUFFER_ALLOC_BOUNDED) { | ||
83 | + /* | ||
84 | + * Used to provide parsing limits | ||
85 | + */ | ||
86 | + if (needSize >= XML_MAX_TEXT_LENGTH) { | ||
87 | + xmlBufMemoryError(buf, "buffer error: text too long\n"); | ||
88 | + return(-1); | ||
89 | + } | ||
90 | + } | ||
91 | if (!xmlBufResize(buf, needSize)){ | ||
92 | xmlBufMemoryError(buf, "growing buffer"); | ||
93 | return XML_ERR_NO_MEMORY; | ||
94 | @@ -938,6 +970,15 @@ xmlBufAddHead(xmlBufPtr buf, const xmlChar *str, int len) { | ||
95 | } | ||
96 | needSize = buf->use + len + 2; | ||
97 | if (needSize > buf->size){ | ||
98 | + if (buf->alloc == XML_BUFFER_ALLOC_BOUNDED) { | ||
99 | + /* | ||
100 | + * Used to provide parsing limits | ||
101 | + */ | ||
102 | + if (needSize >= XML_MAX_TEXT_LENGTH) { | ||
103 | + xmlBufMemoryError(buf, "buffer error: text too long\n"); | ||
104 | + return(-1); | ||
105 | + } | ||
106 | + } | ||
107 | if (!xmlBufResize(buf, needSize)){ | ||
108 | xmlBufMemoryError(buf, "growing buffer"); | ||
109 | return XML_ERR_NO_MEMORY; | ||
110 | diff --git a/include/libxml/tree.h b/include/libxml/tree.h | ||
111 | index 2f90717..4a9b3bc 100644 | ||
112 | --- a/include/libxml/tree.h | ||
113 | +++ b/include/libxml/tree.h | ||
114 | @@ -76,7 +76,8 @@ typedef enum { | ||
115 | XML_BUFFER_ALLOC_EXACT, /* grow only to the minimal size */ | ||
116 | XML_BUFFER_ALLOC_IMMUTABLE, /* immutable buffer */ | ||
117 | XML_BUFFER_ALLOC_IO, /* special allocation scheme used for I/O */ | ||
118 | - XML_BUFFER_ALLOC_HYBRID /* exact up to a threshold, and doubleit thereafter */ | ||
119 | + XML_BUFFER_ALLOC_HYBRID, /* exact up to a threshold, and doubleit thereafter */ | ||
120 | + XML_BUFFER_ALLOC_BOUNDED /* limit the upper size of the buffer */ | ||
121 | } xmlBufferAllocationScheme; | ||
122 | |||
123 | /** | ||
124 | diff --git a/xmlreader.c b/xmlreader.c | ||
125 | index f19e123..471e7e2 100644 | ||
126 | --- a/xmlreader.c | ||
127 | +++ b/xmlreader.c | ||
128 | @@ -2091,6 +2091,9 @@ xmlNewTextReader(xmlParserInputBufferPtr input, const char *URI) { | ||
129 | "xmlNewTextReader : malloc failed\n"); | ||
130 | return(NULL); | ||
131 | } | ||
132 | + /* no operation on a reader should require a huge buffer */ | ||
133 | + xmlBufSetAllocationScheme(ret->buffer, | ||
134 | + XML_BUFFER_ALLOC_BOUNDED); | ||
135 | ret->sax = (xmlSAXHandler *) xmlMalloc(sizeof(xmlSAXHandler)); | ||
136 | if (ret->sax == NULL) { | ||
137 | xmlBufFree(ret->buffer); | ||
138 | @@ -3616,6 +3619,7 @@ xmlTextReaderConstValue(xmlTextReaderPtr reader) { | ||
139 | return(((xmlNsPtr) node)->href); | ||
140 | case XML_ATTRIBUTE_NODE:{ | ||
141 | xmlAttrPtr attr = (xmlAttrPtr) node; | ||
142 | + const xmlChar *ret; | ||
143 | |||
144 | if ((attr->children != NULL) && | ||
145 | (attr->children->type == XML_TEXT_NODE) && | ||
146 | @@ -3629,10 +3633,21 @@ xmlTextReaderConstValue(xmlTextReaderPtr reader) { | ||
147 | "xmlTextReaderSetup : malloc failed\n"); | ||
148 | return (NULL); | ||
149 | } | ||
150 | + xmlBufSetAllocationScheme(reader->buffer, | ||
151 | + XML_BUFFER_ALLOC_BOUNDED); | ||
152 | } else | ||
153 | xmlBufEmpty(reader->buffer); | ||
154 | xmlBufGetNodeContent(reader->buffer, node); | ||
155 | - return(xmlBufContent(reader->buffer)); | ||
156 | + ret = xmlBufContent(reader->buffer); | ||
157 | + if (ret == NULL) { | ||
158 | + /* error on the buffer best to reallocate */ | ||
159 | + xmlBufFree(reader->buffer); | ||
160 | + reader->buffer = xmlBufCreateSize(100); | ||
161 | + xmlBufSetAllocationScheme(reader->buffer, | ||
162 | + XML_BUFFER_ALLOC_BOUNDED); | ||
163 | + ret = BAD_CAST ""; | ||
164 | + } | ||
165 | + return(ret); | ||
166 | } | ||
167 | break; | ||
168 | } | ||
169 | @@ -5131,6 +5146,9 @@ xmlTextReaderSetup(xmlTextReaderPtr reader, | ||
170 | "xmlTextReaderSetup : malloc failed\n"); | ||
171 | return (-1); | ||
172 | } | ||
173 | + /* no operation on a reader should require a huge buffer */ | ||
174 | + xmlBufSetAllocationScheme(reader->buffer, | ||
175 | + XML_BUFFER_ALLOC_BOUNDED); | ||
176 | if (reader->sax == NULL) | ||
177 | reader->sax = (xmlSAXHandler *) xmlMalloc(sizeof(xmlSAXHandler)); | ||
178 | if (reader->sax == NULL) { | ||
179 | -- | ||
180 | 1.7.9.5 | ||
181 | |||
diff --git a/meta/recipes-core/libxml/libxml2/72a46a519ce7326d9a00f0b6a7f2a8e958cd1675.patch b/meta/recipes-core/libxml/libxml2/72a46a519ce7326d9a00f0b6a7f2a8e958cd1675.patch new file mode 100644 index 0000000000..10a8112b58 --- /dev/null +++ b/meta/recipes-core/libxml/libxml2/72a46a519ce7326d9a00f0b6a7f2a8e958cd1675.patch | |||
@@ -0,0 +1,30 @@ | |||
1 | From 72a46a519ce7326d9a00f0b6a7f2a8e958cd1675 Mon Sep 17 00:00:00 2001 | ||
2 | From: Daniel Veillard <veillard@redhat.com> | ||
3 | Date: Thu, 23 Oct 2014 11:35:36 +0800 | ||
4 | Subject: Fix missing entities after CVE-2014-3660 fix | ||
5 | |||
6 | For https://bugzilla.gnome.org/show_bug.cgi?id=738805 | ||
7 | |||
8 | The fix for CVE-2014-3660 introduced a regression in some case | ||
9 | where entity substitution is required and the entity is used | ||
10 | first in anotther entity referenced from an attribute value | ||
11 | |||
12 | Upstream-Status: Backport | ||
13 | |||
14 | diff --git a/parser.c b/parser.c | ||
15 | index 67c9dfd..a8d1b67 100644 | ||
16 | --- a/parser.c | ||
17 | +++ b/parser.c | ||
18 | @@ -7235,7 +7235,8 @@ xmlParseReference(xmlParserCtxtPtr ctxt) { | ||
19 | * far more secure as the parser will only process data coming from | ||
20 | * the document entity by default. | ||
21 | */ | ||
22 | - if ((ent->checked == 0) && | ||
23 | + if (((ent->checked == 0) || | ||
24 | + ((ent->children == NULL) && (ctxt->options & XML_PARSE_NOENT))) && | ||
25 | ((ent->etype != XML_EXTERNAL_GENERAL_PARSED_ENTITY) || | ||
26 | (ctxt->options & (XML_PARSE_NOENT | XML_PARSE_DTDVALID)))) { | ||
27 | unsigned long oldnbent = ctxt->nbentities; | ||
28 | -- | ||
29 | cgit v0.10.1 | ||
30 | |||
diff --git a/meta/recipes-core/libxml/libxml2/ansidecl.patch b/meta/recipes-core/libxml/libxml2/ansidecl.patch new file mode 100644 index 0000000000..2452d780d5 --- /dev/null +++ b/meta/recipes-core/libxml/libxml2/ansidecl.patch | |||
@@ -0,0 +1,25 @@ | |||
1 | Sadly cmake is broken. If it sees this reference and ansidecl is present, it will add a | ||
2 | dependency upon it, even if HAVE_ANSIDEC_H is never set. | ||
3 | |||
4 | The easiest solution is to remove these lines, otherwise recipes like libzypp can have a | ||
5 | dependency on the ansidecl.h header via cmake. This can lead to odd results if the | ||
6 | header is removed (clean binutils) and then the code is recompiled. | ||
7 | |||
8 | RP 2012/7/10 | ||
9 | |||
10 | Upstream-Status: Inappropriate [its really a cmake bug] | ||
11 | |||
12 | Index: libxml2-2.8.0/include/libxml/xmlversion.h.in | ||
13 | =================================================================== | ||
14 | --- libxml2-2.8.0.orig/include/libxml/xmlversion.h.in 2012-07-10 11:51:52.460750573 +0000 | ||
15 | +++ libxml2-2.8.0/include/libxml/xmlversion.h.in 2012-07-10 11:52:41.436749397 +0000 | ||
16 | @@ -401,9 +401,6 @@ | ||
17 | #endif | ||
18 | |||
19 | #ifdef __GNUC__ | ||
20 | -#ifdef HAVE_ANSIDECL_H | ||
21 | -#include <ansidecl.h> | ||
22 | -#endif | ||
23 | |||
24 | /** | ||
25 | * ATTRIBUTE_UNUSED: | ||
diff --git a/meta/recipes-core/libxml/libxml2/libxml-64bit.patch b/meta/recipes-core/libxml/libxml2/libxml-64bit.patch new file mode 100644 index 0000000000..1147017b61 --- /dev/null +++ b/meta/recipes-core/libxml/libxml2/libxml-64bit.patch | |||
@@ -0,0 +1,22 @@ | |||
1 | Upstream-Status: Backport [from debian: bugs.debian.org/439843] | ||
2 | |||
3 | --- | ||
4 | libxml.h | 3 +++ | ||
5 | 1 file changed, 3 insertions(+) | ||
6 | |||
7 | --- libxml2-2.6.29.orig/libxml.h | ||
8 | +++ libxml2-2.6.29/libxml.h | ||
9 | @@ -11,10 +11,13 @@ | ||
10 | |||
11 | #ifndef NO_LARGEFILE_SOURCE | ||
12 | #ifndef _LARGEFILE_SOURCE | ||
13 | #define _LARGEFILE_SOURCE | ||
14 | #endif | ||
15 | +#ifndef _LARGEFILE64_SOURCE | ||
16 | +#define _LARGEFILE64_SOURCE | ||
17 | +#endif | ||
18 | #ifndef _FILE_OFFSET_BITS | ||
19 | #define _FILE_OFFSET_BITS 64 | ||
20 | #endif | ||
21 | #endif | ||
22 | |||
diff --git a/meta/recipes-core/libxml/libxml2/libxml-m4-use-pkgconfig.patch b/meta/recipes-core/libxml/libxml2/libxml-m4-use-pkgconfig.patch new file mode 100644 index 0000000000..0fc84070ed --- /dev/null +++ b/meta/recipes-core/libxml/libxml2/libxml-m4-use-pkgconfig.patch | |||
@@ -0,0 +1,204 @@ | |||
1 | AM_PATH_XML2 uses xml-config which we disable through | ||
2 | binconfig-disabled.bbclass, so port it to use pkg-config instead. | ||
3 | |||
4 | Upstream-Status: Pending | ||
5 | Signed-off-by: Ross Burton <ross.burton@intel.com> | ||
6 | |||
7 | diff --git a/libxml.m4 b/libxml.m4 | ||
8 | index 68cd824..5fa0a9b 100644 | ||
9 | --- a/libxml.m4 | ||
10 | +++ b/libxml.m4 | ||
11 | @@ -1,188 +1,12 @@ | ||
12 | -# Configure paths for LIBXML2 | ||
13 | -# Mike Hommey 2004-06-19 | ||
14 | -# use CPPFLAGS instead of CFLAGS | ||
15 | -# Toshio Kuratomi 2001-04-21 | ||
16 | -# Adapted from: | ||
17 | -# Configure paths for GLIB | ||
18 | -# Owen Taylor 97-11-3 | ||
19 | - | ||
20 | dnl AM_PATH_XML2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) | ||
21 | dnl Test for XML, and define XML_CPPFLAGS and XML_LIBS | ||
22 | dnl | ||
23 | -AC_DEFUN([AM_PATH_XML2],[ | ||
24 | -AC_ARG_WITH(xml-prefix, | ||
25 | - [ --with-xml-prefix=PFX Prefix where libxml is installed (optional)], | ||
26 | - xml_config_prefix="$withval", xml_config_prefix="") | ||
27 | -AC_ARG_WITH(xml-exec-prefix, | ||
28 | - [ --with-xml-exec-prefix=PFX Exec prefix where libxml is installed (optional)], | ||
29 | - xml_config_exec_prefix="$withval", xml_config_exec_prefix="") | ||
30 | -AC_ARG_ENABLE(xmltest, | ||
31 | - [ --disable-xmltest Do not try to compile and run a test LIBXML program],, | ||
32 | - enable_xmltest=yes) | ||
33 | - | ||
34 | - if test x$xml_config_exec_prefix != x ; then | ||
35 | - xml_config_args="$xml_config_args" | ||
36 | - if test x${XML2_CONFIG+set} != xset ; then | ||
37 | - XML2_CONFIG=$xml_config_exec_prefix/bin/xml2-config | ||
38 | - fi | ||
39 | - fi | ||
40 | - if test x$xml_config_prefix != x ; then | ||
41 | - xml_config_args="$xml_config_args --prefix=$xml_config_prefix" | ||
42 | - if test x${XML2_CONFIG+set} != xset ; then | ||
43 | - XML2_CONFIG=$xml_config_prefix/bin/xml2-config | ||
44 | - fi | ||
45 | - fi | ||
46 | - | ||
47 | - AC_PATH_PROG(XML2_CONFIG, xml2-config, no) | ||
48 | - min_xml_version=ifelse([$1], ,2.0.0,[$1]) | ||
49 | - AC_MSG_CHECKING(for libxml - version >= $min_xml_version) | ||
50 | - no_xml="" | ||
51 | - if test "$XML2_CONFIG" = "no" ; then | ||
52 | - no_xml=yes | ||
53 | - else | ||
54 | - XML_CPPFLAGS=`$XML2_CONFIG $xml_config_args --cflags` | ||
55 | - XML_LIBS=`$XML2_CONFIG $xml_config_args --libs` | ||
56 | - xml_config_major_version=`$XML2_CONFIG $xml_config_args --version | \ | ||
57 | - sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` | ||
58 | - xml_config_minor_version=`$XML2_CONFIG $xml_config_args --version | \ | ||
59 | - sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` | ||
60 | - xml_config_micro_version=`$XML2_CONFIG $xml_config_args --version | \ | ||
61 | - sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` | ||
62 | - if test "x$enable_xmltest" = "xyes" ; then | ||
63 | - ac_save_CPPFLAGS="$CPPFLAGS" | ||
64 | - ac_save_LIBS="$LIBS" | ||
65 | - CPPFLAGS="$CPPFLAGS $XML_CPPFLAGS" | ||
66 | - LIBS="$XML_LIBS $LIBS" | ||
67 | -dnl | ||
68 | -dnl Now check if the installed libxml is sufficiently new. | ||
69 | -dnl (Also sanity checks the results of xml2-config to some extent) | ||
70 | -dnl | ||
71 | - rm -f conf.xmltest | ||
72 | - AC_TRY_RUN([ | ||
73 | -#include <stdlib.h> | ||
74 | -#include <stdio.h> | ||
75 | -#include <string.h> | ||
76 | -#include <libxml/xmlversion.h> | ||
77 | - | ||
78 | -int | ||
79 | -main() | ||
80 | -{ | ||
81 | - int xml_major_version, xml_minor_version, xml_micro_version; | ||
82 | - int major, minor, micro; | ||
83 | - char *tmp_version; | ||
84 | - | ||
85 | - system("touch conf.xmltest"); | ||
86 | - | ||
87 | - /* Capture xml2-config output via autoconf/configure variables */ | ||
88 | - /* HP/UX 9 (%@#!) writes to sscanf strings */ | ||
89 | - tmp_version = (char *)strdup("$min_xml_version"); | ||
90 | - if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { | ||
91 | - printf("%s, bad version string from xml2-config\n", "$min_xml_version"); | ||
92 | - exit(1); | ||
93 | - } | ||
94 | - free(tmp_version); | ||
95 | - | ||
96 | - /* Capture the version information from the header files */ | ||
97 | - tmp_version = (char *)strdup(LIBXML_DOTTED_VERSION); | ||
98 | - if (sscanf(tmp_version, "%d.%d.%d", &xml_major_version, &xml_minor_version, &xml_micro_version) != 3) { | ||
99 | - printf("%s, bad version string from libxml includes\n", "LIBXML_DOTTED_VERSION"); | ||
100 | - exit(1); | ||
101 | - } | ||
102 | - free(tmp_version); | ||
103 | - | ||
104 | - /* Compare xml2-config output to the libxml headers */ | ||
105 | - if ((xml_major_version != $xml_config_major_version) || | ||
106 | - (xml_minor_version != $xml_config_minor_version) || | ||
107 | - (xml_micro_version != $xml_config_micro_version)) | ||
108 | - { | ||
109 | - printf("*** libxml header files (version %d.%d.%d) do not match\n", | ||
110 | - xml_major_version, xml_minor_version, xml_micro_version); | ||
111 | - printf("*** xml2-config (version %d.%d.%d)\n", | ||
112 | - $xml_config_major_version, $xml_config_minor_version, $xml_config_micro_version); | ||
113 | - return 1; | ||
114 | - } | ||
115 | -/* Compare the headers to the library to make sure we match */ | ||
116 | - /* Less than ideal -- doesn't provide us with return value feedback, | ||
117 | - * only exits if there's a serious mismatch between header and library. | ||
118 | - */ | ||
119 | - LIBXML_TEST_VERSION; | ||
120 | - | ||
121 | - /* Test that the library is greater than our minimum version */ | ||
122 | - if ((xml_major_version > major) || | ||
123 | - ((xml_major_version == major) && (xml_minor_version > minor)) || | ||
124 | - ((xml_major_version == major) && (xml_minor_version == minor) && | ||
125 | - (xml_micro_version >= micro))) | ||
126 | - { | ||
127 | - return 0; | ||
128 | - } | ||
129 | - else | ||
130 | - { | ||
131 | - printf("\n*** An old version of libxml (%d.%d.%d) was found.\n", | ||
132 | - xml_major_version, xml_minor_version, xml_micro_version); | ||
133 | - printf("*** You need a version of libxml newer than %d.%d.%d. The latest version of\n", | ||
134 | - major, minor, micro); | ||
135 | - printf("*** libxml is always available from ftp://ftp.xmlsoft.org.\n"); | ||
136 | - printf("***\n"); | ||
137 | - printf("*** If you have already installed a sufficiently new version, this error\n"); | ||
138 | - printf("*** probably means that the wrong copy of the xml2-config shell script is\n"); | ||
139 | - printf("*** being found. The easiest way to fix this is to remove the old version\n"); | ||
140 | - printf("*** of LIBXML, but you can also set the XML2_CONFIG environment to point to the\n"); | ||
141 | - printf("*** correct copy of xml2-config. (In this case, you will have to\n"); | ||
142 | - printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n"); | ||
143 | - printf("*** so that the correct libraries are found at run-time))\n"); | ||
144 | - } | ||
145 | - return 1; | ||
146 | -} | ||
147 | -],, no_xml=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) | ||
148 | - CPPFLAGS="$ac_save_CPPFLAGS" | ||
149 | - LIBS="$ac_save_LIBS" | ||
150 | - fi | ||
151 | - fi | ||
152 | +AC_DEFUN([AM_PATH_XML2],[ | ||
153 | + AC_REQUIRE([PKG_PROG_PKG_CONFIG]) | ||
154 | |||
155 | - if test "x$no_xml" = x ; then | ||
156 | - AC_MSG_RESULT(yes (version $xml_config_major_version.$xml_config_minor_version.$xml_config_micro_version)) | ||
157 | - ifelse([$2], , :, [$2]) | ||
158 | - else | ||
159 | - AC_MSG_RESULT(no) | ||
160 | - if test "$XML2_CONFIG" = "no" ; then | ||
161 | - echo "*** The xml2-config script installed by LIBXML could not be found" | ||
162 | - echo "*** If libxml was installed in PREFIX, make sure PREFIX/bin is in" | ||
163 | - echo "*** your path, or set the XML2_CONFIG environment variable to the" | ||
164 | - echo "*** full path to xml2-config." | ||
165 | - else | ||
166 | - if test -f conf.xmltest ; then | ||
167 | - : | ||
168 | - else | ||
169 | - echo "*** Could not run libxml test program, checking why..." | ||
170 | - CPPFLAGS="$CPPFLAGS $XML_CPPFLAGS" | ||
171 | - LIBS="$LIBS $XML_LIBS" | ||
172 | - AC_TRY_LINK([ | ||
173 | -#include <libxml/xmlversion.h> | ||
174 | -#include <stdio.h> | ||
175 | -], [ LIBXML_TEST_VERSION; return 0;], | ||
176 | - [ echo "*** The test program compiled, but did not run. This usually means" | ||
177 | - echo "*** that the run-time linker is not finding LIBXML or finding the wrong" | ||
178 | - echo "*** version of LIBXML. If it is not finding LIBXML, you'll need to set your" | ||
179 | - echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" | ||
180 | - echo "*** to the installed location Also, make sure you have run ldconfig if that" | ||
181 | - echo "*** is required on your system" | ||
182 | - echo "***" | ||
183 | - echo "*** If you have an old version installed, it is best to remove it, although" | ||
184 | - echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ], | ||
185 | - [ echo "*** The test program failed to compile or link. See the file config.log for the" | ||
186 | - echo "*** exact error that occured. This usually means LIBXML was incorrectly installed" | ||
187 | - echo "*** or that you have moved LIBXML since it was installed. In the latter case, you" | ||
188 | - echo "*** may want to edit the xml2-config script: $XML2_CONFIG" ]) | ||
189 | - CPPFLAGS="$ac_save_CPPFLAGS" | ||
190 | - LIBS="$ac_save_LIBS" | ||
191 | - fi | ||
192 | - fi | ||
193 | + verdep=ifelse([$1], [], [], [>= $1]) | ||
194 | + PKG_CHECK_MODULES(XML, [libxml-2.0 $verdep], [$2], [$3]) | ||
195 | |||
196 | - XML_CPPFLAGS="" | ||
197 | - XML_LIBS="" | ||
198 | - ifelse([$3], , :, [$3]) | ||
199 | - fi | ||
200 | + XML_CPPFLAGS=$XML_CFLAGS | ||
201 | AC_SUBST(XML_CPPFLAGS) | ||
202 | - AC_SUBST(XML_LIBS) | ||
203 | - rm -f conf.xmltest | ||
204 | ]) | ||
diff --git a/meta/recipes-core/libxml/libxml2/libxml2-CVE-2014-0191-fix.patch b/meta/recipes-core/libxml/libxml2/libxml2-CVE-2014-0191-fix.patch new file mode 100644 index 0000000000..1c05ae649e --- /dev/null +++ b/meta/recipes-core/libxml/libxml2/libxml2-CVE-2014-0191-fix.patch | |||
@@ -0,0 +1,37 @@ | |||
1 | From: Daniel Veillard <veillard@redhat.com> | ||
2 | Date: Tue, 22 Apr 2014 15:30:56 +0800 | ||
3 | Subject: Do not fetch external parameter entities | ||
4 | |||
5 | Unless explicitely asked for when validating or replacing entities | ||
6 | with their value. Problem pointed out by Daniel Berrange <berrange@redhat.com> | ||
7 | |||
8 | Upstream-Status: Backport | ||
9 | Reference: https://access.redhat.com/security/cve/CVE-2014-0191 | ||
10 | |||
11 | Signed-off-by: Daniel Veillard <veillard@redhat.com> | ||
12 | Signed-off-by: Maxin B. John <maxin.john@enea.com> | ||
13 | --- | ||
14 | diff -Naur libxml2-2.9.1-orig/parser.c libxml2-2.9.1/parser.c | ||
15 | --- libxml2-2.9.1-orig/parser.c 2013-04-16 15:39:18.000000000 +0200 | ||
16 | +++ libxml2-2.9.1/parser.c 2014-05-07 13:35:46.883687946 +0200 | ||
17 | @@ -2595,6 +2595,20 @@ | ||
18 | xmlCharEncoding enc; | ||
19 | |||
20 | /* | ||
21 | + * Note: external parsed entities will not be loaded, it is | ||
22 | + * not required for a non-validating parser, unless the | ||
23 | + * option of validating, or substituting entities were | ||
24 | + * given. Doing so is far more secure as the parser will | ||
25 | + * only process data coming from the document entity by | ||
26 | + * default. | ||
27 | + */ | ||
28 | + if ((entity->etype == XML_EXTERNAL_PARAMETER_ENTITY) && | ||
29 | + ((ctxt->options & XML_PARSE_NOENT) == 0) && | ||
30 | + ((ctxt->options & XML_PARSE_DTDVALID) == 0) && | ||
31 | + (ctxt->validate == 0)) | ||
32 | + return; | ||
33 | + | ||
34 | + /* | ||
35 | * handle the extra spaces added before and after | ||
36 | * c.f. http://www.w3.org/TR/REC-xml#as-PE | ||
37 | * this is done independently. | ||
diff --git a/meta/recipes-core/libxml/libxml2/libxml2-CVE-2014-3660.patch b/meta/recipes-core/libxml/libxml2/libxml2-CVE-2014-3660.patch new file mode 100644 index 0000000000..b9621c93eb --- /dev/null +++ b/meta/recipes-core/libxml/libxml2/libxml2-CVE-2014-3660.patch | |||
@@ -0,0 +1,147 @@ | |||
1 | From be2a7edaf289c5da74a4f9ed3a0b6c733e775230 Mon Sep 17 00:00:00 2001 | ||
2 | From: Daniel Veillard <veillard@redhat.com> | ||
3 | Date: Thu, 16 Oct 2014 13:59:47 +0800 | ||
4 | Subject: Fix for CVE-2014-3660 | ||
5 | |||
6 | Issues related to the billion laugh entity expansion which happened to | ||
7 | escape the initial set of fixes | ||
8 | |||
9 | Upstream-status: Backport | ||
10 | Reference: https://git.gnome.org/browse/libxml2/commit/?id=be2a7edaf289c5da74a4f9ed3a0b6c733e775230&context=3&ignorews=0&ss=0 | ||
11 | |||
12 | Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com> | ||
13 | |||
14 | diff --git a/parser.c b/parser.c | ||
15 | index f51e8d2..1d93967 100644 | ||
16 | --- a/parser.c | ||
17 | +++ b/parser.c | ||
18 | @@ -130,6 +130,29 @@ xmlParserEntityCheck(xmlParserCtxtPtr ctxt, size_t size, | ||
19 | return (0); | ||
20 | if (ctxt->lastError.code == XML_ERR_ENTITY_LOOP) | ||
21 | return (1); | ||
22 | + | ||
23 | + /* | ||
24 | + * This may look absurd but is needed to detect | ||
25 | + * entities problems | ||
26 | + */ | ||
27 | + if ((ent != NULL) && (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) && | ||
28 | + (ent->content != NULL) && (ent->checked == 0)) { | ||
29 | + unsigned long oldnbent = ctxt->nbentities; | ||
30 | + xmlChar *rep; | ||
31 | + | ||
32 | + ent->checked = 1; | ||
33 | + | ||
34 | + rep = xmlStringDecodeEntities(ctxt, ent->content, | ||
35 | + XML_SUBSTITUTE_REF, 0, 0, 0); | ||
36 | + | ||
37 | + ent->checked = (ctxt->nbentities - oldnbent + 1) * 2; | ||
38 | + if (rep != NULL) { | ||
39 | + if (xmlStrchr(rep, '<')) | ||
40 | + ent->checked |= 1; | ||
41 | + xmlFree(rep); | ||
42 | + rep = NULL; | ||
43 | + } | ||
44 | + } | ||
45 | if (replacement != 0) { | ||
46 | if (replacement < XML_MAX_TEXT_LENGTH) | ||
47 | return(0); | ||
48 | @@ -189,9 +212,12 @@ xmlParserEntityCheck(xmlParserCtxtPtr ctxt, size_t size, | ||
49 | return (0); | ||
50 | } else { | ||
51 | /* | ||
52 | - * strange we got no data for checking just return | ||
53 | + * strange we got no data for checking | ||
54 | */ | ||
55 | - return (0); | ||
56 | + if (((ctxt->lastError.code != XML_ERR_UNDECLARED_ENTITY) && | ||
57 | + (ctxt->lastError.code != XML_WAR_UNDECLARED_ENTITY)) || | ||
58 | + (ctxt->nbentities <= 10000)) | ||
59 | + return (0); | ||
60 | } | ||
61 | xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL); | ||
62 | return (1); | ||
63 | @@ -2589,6 +2615,7 @@ xmlParserHandlePEReference(xmlParserCtxtPtr ctxt) { | ||
64 | name, NULL); | ||
65 | ctxt->valid = 0; | ||
66 | } | ||
67 | + xmlParserEntityCheck(ctxt, 0, NULL, 0); | ||
68 | } else if (ctxt->input->free != deallocblankswrapper) { | ||
69 | input = xmlNewBlanksWrapperInputStream(ctxt, entity); | ||
70 | if (xmlPushInput(ctxt, input) < 0) | ||
71 | @@ -2759,6 +2786,7 @@ xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len, | ||
72 | if ((ctxt->lastError.code == XML_ERR_ENTITY_LOOP) || | ||
73 | (ctxt->lastError.code == XML_ERR_INTERNAL_ERROR)) | ||
74 | goto int_error; | ||
75 | + xmlParserEntityCheck(ctxt, 0, ent, 0); | ||
76 | if (ent != NULL) | ||
77 | ctxt->nbentities += ent->checked / 2; | ||
78 | if ((ent != NULL) && | ||
79 | @@ -2810,6 +2838,7 @@ xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len, | ||
80 | ent = xmlParseStringPEReference(ctxt, &str); | ||
81 | if (ctxt->lastError.code == XML_ERR_ENTITY_LOOP) | ||
82 | goto int_error; | ||
83 | + xmlParserEntityCheck(ctxt, 0, ent, 0); | ||
84 | if (ent != NULL) | ||
85 | ctxt->nbentities += ent->checked / 2; | ||
86 | if (ent != NULL) { | ||
87 | @@ -7312,6 +7341,7 @@ xmlParseReference(xmlParserCtxtPtr ctxt) { | ||
88 | (ret != XML_WAR_UNDECLARED_ENTITY)) { | ||
89 | xmlFatalErrMsgStr(ctxt, XML_ERR_UNDECLARED_ENTITY, | ||
90 | "Entity '%s' failed to parse\n", ent->name); | ||
91 | + xmlParserEntityCheck(ctxt, 0, ent, 0); | ||
92 | } else if (list != NULL) { | ||
93 | xmlFreeNodeList(list); | ||
94 | list = NULL; | ||
95 | @@ -7418,7 +7448,7 @@ xmlParseReference(xmlParserCtxtPtr ctxt) { | ||
96 | /* | ||
97 | * We are copying here, make sure there is no abuse | ||
98 | */ | ||
99 | - ctxt->sizeentcopy += ent->length; | ||
100 | + ctxt->sizeentcopy += ent->length + 5; | ||
101 | if (xmlParserEntityCheck(ctxt, 0, ent, ctxt->sizeentcopy)) | ||
102 | return; | ||
103 | |||
104 | @@ -7466,7 +7496,7 @@ xmlParseReference(xmlParserCtxtPtr ctxt) { | ||
105 | /* | ||
106 | * We are copying here, make sure there is no abuse | ||
107 | */ | ||
108 | - ctxt->sizeentcopy += ent->length; | ||
109 | + ctxt->sizeentcopy += ent->length + 5; | ||
110 | if (xmlParserEntityCheck(ctxt, 0, ent, ctxt->sizeentcopy)) | ||
111 | return; | ||
112 | |||
113 | @@ -7652,6 +7682,7 @@ xmlParseEntityRef(xmlParserCtxtPtr ctxt) { | ||
114 | ctxt->sax->reference(ctxt->userData, name); | ||
115 | } | ||
116 | } | ||
117 | + xmlParserEntityCheck(ctxt, 0, ent, 0); | ||
118 | ctxt->valid = 0; | ||
119 | } | ||
120 | |||
121 | @@ -7845,6 +7876,7 @@ xmlParseStringEntityRef(xmlParserCtxtPtr ctxt, const xmlChar ** str) { | ||
122 | "Entity '%s' not defined\n", | ||
123 | name); | ||
124 | } | ||
125 | + xmlParserEntityCheck(ctxt, 0, ent, 0); | ||
126 | /* TODO ? check regressions ctxt->valid = 0; */ | ||
127 | } | ||
128 | |||
129 | @@ -8004,6 +8036,7 @@ xmlParsePEReference(xmlParserCtxtPtr ctxt) | ||
130 | name, NULL); | ||
131 | ctxt->valid = 0; | ||
132 | } | ||
133 | + xmlParserEntityCheck(ctxt, 0, NULL, 0); | ||
134 | } else { | ||
135 | /* | ||
136 | * Internal checking in case the entity quest barfed | ||
137 | @@ -8243,6 +8276,7 @@ xmlParseStringPEReference(xmlParserCtxtPtr ctxt, const xmlChar **str) { | ||
138 | name, NULL); | ||
139 | ctxt->valid = 0; | ||
140 | } | ||
141 | + xmlParserEntityCheck(ctxt, 0, NULL, 0); | ||
142 | } else { | ||
143 | /* | ||
144 | * Internal checking in case the entity quest barfed | ||
145 | -- | ||
146 | cgit v0.10.1 | ||
147 | |||
diff --git a/meta/recipes-core/libxml/libxml2/python-sitepackages-dir.patch b/meta/recipes-core/libxml/libxml2/python-sitepackages-dir.patch new file mode 100644 index 0000000000..a697ddf873 --- /dev/null +++ b/meta/recipes-core/libxml/libxml2/python-sitepackages-dir.patch | |||
@@ -0,0 +1,21 @@ | |||
1 | Allow us to pass in PYTHON_SITE_PACKAGES | ||
2 | |||
3 | The python binary used when building for nativesdk doesn't give us the | ||
4 | correct path here so we need to be able to specify it ourselves. | ||
5 | |||
6 | Upstream-Status: Inappropriate [config] | ||
7 | |||
8 | Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> | ||
9 | |||
10 | --- a/configure.in | ||
11 | +++ b/configure.in | ||
12 | @@ -743,7 +743,8 @@ dnl | ||
13 | |||
14 | PYTHON_VERSION= | ||
15 | PYTHON_INCLUDES= | ||
16 | -PYTHON_SITE_PACKAGES= | ||
17 | +# Allow this to be set externally | ||
18 | +#PYTHON_SITE_PACKAGES= | ||
19 | PYTHON_TESTS= | ||
20 | pythondir= | ||
21 | if test "$with_python" != "no" ; then | ||
diff --git a/meta/recipes-core/libxml/libxml2/run-ptest b/meta/recipes-core/libxml/libxml2/run-ptest new file mode 100644 index 0000000000..473d0b67a7 --- /dev/null +++ b/meta/recipes-core/libxml/libxml2/run-ptest | |||
@@ -0,0 +1,3 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | make -k runtests | ||
diff --git a/meta/recipes-core/libxml/libxml2/runtest.patch b/meta/recipes-core/libxml/libxml2/runtest.patch new file mode 100644 index 0000000000..397ab20c30 --- /dev/null +++ b/meta/recipes-core/libxml/libxml2/runtest.patch | |||
@@ -0,0 +1,820 @@ | |||
1 | Add 'install-ptest' rule. | ||
2 | Print a standard result line for each test. | ||
3 | |||
4 | Signed-off-by: Mihaela Sendrea <mihaela.sendrea@enea.com> | ||
5 | Upstream-Status: Pending | ||
6 | |||
7 | diff -uNr a/Makefile.am b/Makefile.am | ||
8 | --- a/Makefile.am 2013-04-17 14:51:42.633386477 +0200 | ||
9 | +++ b/Makefile.am 2013-04-19 14:47:51.544720568 +0200 | ||
10 | @@ -202,10 +202,19 @@ | ||
11 | #testOOM_DEPENDENCIES = $(DEPS) | ||
12 | #testOOM_LDADD= $(LDADDS) | ||
13 | |||
14 | +install-ptest: | ||
15 | + @(if [ -d .libs ] ; then cd .libs; fi; \ | ||
16 | + install $(noinst_PROGRAMS) $(DESTDIR)) | ||
17 | + cp -r $(srcdir)/test $(DESTDIR) | ||
18 | + cp -r $(srcdir)/result $(DESTDIR) | ||
19 | + cp -r $(srcdir)/python $(DESTDIR) | ||
20 | + cp Makefile $(DESTDIR) | ||
21 | + sed -i -e 's|^Makefile:|_Makefile:|' $(DESTDIR)/Makefile | ||
22 | + | ||
23 | runtests: | ||
24 | [ -d test ] || $(LN_S) $(srcdir)/test . | ||
25 | [ -d result ] || $(LN_S) $(srcdir)/result . | ||
26 | - $(CHECKER) ./runtest$(EXEEXT) && $(CHECKER) ./testrecurse$(EXEEXT) &&$(CHECKER) ./testapi$(EXEEXT) && $(CHECKER) ./testchar$(EXEEXT)&& $(CHECKER) ./testdict$(EXEEXT) && $(CHECKER) ./runxmlconf$(EXEEXT) | ||
27 | + ./runtest$(EXEEXT) ; ./testrecurse$(EXEEXT) ; ./testapi$(EXEEXT) ; ./testchar$(EXEEXT) ; ./testdict$(EXEEXT) ; ./runxmlconf$(EXEEXT) | ||
28 | @(if [ "$(PYTHON_SUBDIR)" != "" ] ; then cd python ; \ | ||
29 | $(MAKE) tests ; fi) | ||
30 | |||
31 | diff -uNr a/runsuite.c b/runsuite.c | ||
32 | --- a/runsuite.c 2013-04-12 16:17:11.462823238 +0200 | ||
33 | +++ b/runsuite.c 2013-04-17 14:07:24.352693211 +0200 | ||
34 | @@ -1162,6 +1162,7 @@ | ||
35 | |||
36 | if (logfile != NULL) | ||
37 | fclose(logfile); | ||
38 | + printf("%s: runsuite\n\n", (ret == 0) ? "PASS" : "FAIL"); | ||
39 | return(ret); | ||
40 | } | ||
41 | #else /* !SCHEMAS */ | ||
42 | diff -uNr a/runtest.c b/runtest.c | ||
43 | --- a/runtest.c 2013-04-16 13:19:15.087997290 +0200 | ||
44 | +++ b/runtest.c 2013-04-17 14:08:29.529949655 +0200 | ||
45 | @@ -4386,6 +4386,7 @@ | ||
46 | err++; | ||
47 | } | ||
48 | } | ||
49 | + printf("%s: %s\n", (err == 0) ? "PASS" : "FAIL", tst->desc); | ||
50 | return(err); | ||
51 | } | ||
52 | |||
53 | @@ -4455,6 +4456,7 @@ | ||
54 | xmlCleanupParser(); | ||
55 | xmlMemoryDump(); | ||
56 | |||
57 | + printf("%s: runtest\n\n", (ret == 0) ? "PASS" : "FAIL"); | ||
58 | return(ret); | ||
59 | } | ||
60 | |||
61 | diff -uNr a/runxmlconf.c b/runxmlconf.c | ||
62 | --- a/runxmlconf.c 2013-04-16 12:53:49.900982990 +0200 | ||
63 | +++ b/runxmlconf.c 2013-04-17 14:09:21.111778104 +0200 | ||
64 | @@ -595,6 +595,7 @@ | ||
65 | |||
66 | if (logfile != NULL) | ||
67 | fclose(logfile); | ||
68 | + printf("%s: runxmlconf\n", (ret == 0) ? "PASS" : "FAIL"); | ||
69 | return(ret); | ||
70 | } | ||
71 | |||
72 | diff -uNr a/testapi.c b/testapi.c | ||
73 | --- a/testapi.c 2013-04-12 16:16:57.763417659 +0200 | ||
74 | +++ b/testapi.c 2013-04-17 14:10:28.876924881 +0200 | ||
75 | @@ -1245,49 +1245,91 @@ | ||
76 | testlibxml2(void) | ||
77 | { | ||
78 | int test_ret = 0; | ||
79 | + int ret = 0; | ||
80 | |||
81 | - test_ret += test_HTMLparser(); | ||
82 | - test_ret += test_HTMLtree(); | ||
83 | - test_ret += test_SAX2(); | ||
84 | - test_ret += test_c14n(); | ||
85 | - test_ret += test_catalog(); | ||
86 | - test_ret += test_chvalid(); | ||
87 | - test_ret += test_debugXML(); | ||
88 | - test_ret += test_dict(); | ||
89 | - test_ret += test_encoding(); | ||
90 | - test_ret += test_entities(); | ||
91 | - test_ret += test_hash(); | ||
92 | - test_ret += test_list(); | ||
93 | - test_ret += test_nanoftp(); | ||
94 | - test_ret += test_nanohttp(); | ||
95 | - test_ret += test_parser(); | ||
96 | - test_ret += test_parserInternals(); | ||
97 | - test_ret += test_pattern(); | ||
98 | - test_ret += test_relaxng(); | ||
99 | - test_ret += test_schemasInternals(); | ||
100 | - test_ret += test_schematron(); | ||
101 | - test_ret += test_tree(); | ||
102 | - test_ret += test_uri(); | ||
103 | - test_ret += test_valid(); | ||
104 | - test_ret += test_xinclude(); | ||
105 | - test_ret += test_xmlIO(); | ||
106 | - test_ret += test_xmlautomata(); | ||
107 | - test_ret += test_xmlerror(); | ||
108 | - test_ret += test_xmlmodule(); | ||
109 | - test_ret += test_xmlreader(); | ||
110 | - test_ret += test_xmlregexp(); | ||
111 | - test_ret += test_xmlsave(); | ||
112 | - test_ret += test_xmlschemas(); | ||
113 | - test_ret += test_xmlschemastypes(); | ||
114 | - test_ret += test_xmlstring(); | ||
115 | - test_ret += test_xmlunicode(); | ||
116 | - test_ret += test_xmlwriter(); | ||
117 | - test_ret += test_xpath(); | ||
118 | - test_ret += test_xpathInternals(); | ||
119 | - test_ret += test_xpointer(); | ||
120 | + test_ret += (ret = test_HTMLparser()); | ||
121 | + printf("%s: HTMLparser\n", (ret == 0) ? "PASS" : "FAIL"); | ||
122 | + test_ret += (ret = test_HTMLtree()); | ||
123 | + printf("%s: HTMLtree\n", (ret == 0) ? "PASS" : "FAIL"); | ||
124 | + test_ret += (ret = test_SAX2()); | ||
125 | + printf("%s: SAX2\n", (ret == 0) ? "PASS" : "FAIL"); | ||
126 | + test_ret += (ret = test_c14n()); | ||
127 | + printf("%s: c14n\n", (ret == 0) ? "PASS" : "FAIL"); | ||
128 | + test_ret += (ret = test_catalog()); | ||
129 | + printf("%s: catalog\n", (ret == 0) ? "PASS" : "FAIL"); | ||
130 | + test_ret += (ret = test_chvalid()); | ||
131 | + printf("%s: chvalid\n", (ret == 0) ? "PASS" : "FAIL"); | ||
132 | + test_ret += (ret = test_debugXML()); | ||
133 | + printf("%s: debugXML\n", (ret == 0) ? "PASS" : "FAIL"); | ||
134 | + test_ret += (ret = test_dict()); | ||
135 | + printf("%s: dict\n", (ret == 0) ? "PASS" : "FAIL"); | ||
136 | + test_ret += (ret = test_encoding()); | ||
137 | + printf("%s: encoding\n", (ret == 0) ? "PASS" : "FAIL"); | ||
138 | + test_ret += (ret = test_entities()); | ||
139 | + printf("%s: entities\n", (ret == 0) ? "PASS" : "FAIL"); | ||
140 | + test_ret += (ret = test_hash()); | ||
141 | + printf("%s: hash\n", (ret == 0) ? "PASS" : "FAIL"); | ||
142 | + test_ret += (ret = test_list()); | ||
143 | + printf("%s: list\n", (ret == 0) ? "PASS" : "FAIL"); | ||
144 | + test_ret += (ret = test_nanoftp()); | ||
145 | + printf("%s: nanoftp\n", (ret == 0) ? "PASS" : "FAIL"); | ||
146 | + test_ret += (ret = test_nanohttp()); | ||
147 | + printf("%s: nanohttp\n", (ret == 0) ? "PASS" : "FAIL"); | ||
148 | + test_ret += (ret = test_parser()); | ||
149 | + printf("%s: parser\n", (ret == 0) ? "PASS" : "FAIL"); | ||
150 | + test_ret += (ret = test_parserInternals()); | ||
151 | + printf("%s: parserInternals\n", (ret == 0) ? "PASS" : "FAIL"); | ||
152 | + test_ret += (ret = test_pattern()); | ||
153 | + printf("%s: pattern\n", (ret == 0) ? "PASS" : "FAIL"); | ||
154 | + test_ret += (ret = test_relaxng()); | ||
155 | + printf("%s: relaxng\n", (ret == 0) ? "PASS" : "FAIL"); | ||
156 | + test_ret += (ret = test_schemasInternals()); | ||
157 | + printf("%s: schemasInternals\n", (ret == 0) ? "PASS" : "FAIL"); | ||
158 | + test_ret += (ret = test_schematron()); | ||
159 | + printf("%s: schematron\n", (ret == 0) ? "PASS" : "FAIL"); | ||
160 | + test_ret += (ret = test_tree()); | ||
161 | + printf("%s: tree\n", (ret == 0) ? "PASS" : "FAIL"); | ||
162 | + test_ret += (ret = test_uri()); | ||
163 | + printf("%s: uri\n", (ret == 0) ? "PASS" : "FAIL"); | ||
164 | + test_ret += (ret = test_valid()); | ||
165 | + printf("%s: valid\n", (ret == 0) ? "PASS" : "FAIL"); | ||
166 | + test_ret += (ret = test_xinclude()); | ||
167 | + printf("%s: xinclude\n", (ret == 0) ? "PASS" : "FAIL"); | ||
168 | + test_ret += (ret = test_xmlIO()); | ||
169 | + printf("%s: xmlIO\n", (ret == 0) ? "PASS" : "FAIL"); | ||
170 | + test_ret += (ret = test_xmlautomata()); | ||
171 | + printf("%s: xmlautomata\n", (ret == 0) ? "PASS" : "FAIL"); | ||
172 | + test_ret += (ret = test_xmlerror()); | ||
173 | + printf("%s: xmlerror\n", (ret == 0) ? "PASS" : "FAIL"); | ||
174 | + test_ret += (ret = test_xmlmodule()); | ||
175 | + printf("%s: xmlmodule\n", (ret == 0) ? "PASS" : "FAIL"); | ||
176 | + test_ret += (ret = test_xmlreader()); | ||
177 | + printf("%s: xmlreader\n", (ret == 0) ? "PASS" : "FAIL"); | ||
178 | + test_ret += (ret = test_xmlregexp()); | ||
179 | + printf("%s: xmlregexp\n", (ret == 0) ? "PASS" : "FAIL"); | ||
180 | + test_ret += (ret = test_xmlsave()); | ||
181 | + printf("%s: xmlsave\n", (ret == 0) ? "PASS" : "FAIL"); | ||
182 | + test_ret += (ret = test_xmlschemas()); | ||
183 | + printf("%s: xmlschemas\n", (ret == 0) ? "PASS" : "FAIL"); | ||
184 | + test_ret += (ret = test_xmlschemastypes()); | ||
185 | + printf("%s: xmlschemastypes\n", (ret == 0) ? "PASS" : "FAIL"); | ||
186 | + test_ret += (ret = test_xmlstring()); | ||
187 | + printf("%s: xmlstring\n", (ret == 0) ? "PASS" : "FAIL"); | ||
188 | + test_ret += (ret = test_xmlunicode()); | ||
189 | + printf("%s: xmlunicode\n", (ret == 0) ? "PASS" : "FAIL"); | ||
190 | + test_ret += (ret = test_xmlwriter()); | ||
191 | + printf("%s: xmlwriter\n", (ret == 0) ? "PASS" : "FAIL"); | ||
192 | + test_ret += (ret = test_xpath()); | ||
193 | + printf("%s: xpath\n", (ret == 0) ? "PASS" : "FAIL"); | ||
194 | + test_ret += (ret = test_xpathInternals()); | ||
195 | + printf("%s: xpathInternals\n", (ret == 0) ? "PASS" : "FAIL"); | ||
196 | + test_ret += (ret = test_xpointer()); | ||
197 | + printf("%s: xpointer\n", (ret == 0) ? "PASS" : "FAIL"); | ||
198 | |||
199 | printf("Total: %d functions, %d tests, %d errors\n", | ||
200 | function_tests, call_tests, test_ret); | ||
201 | + | ||
202 | + printf("%s: testapi\n\n", (test_ret == 0) ? "PASS" : "FAIL"); | ||
203 | return(test_ret); | ||
204 | } | ||
205 | |||
206 | diff -uNr a/testchar.c b/testchar.c | ||
207 | --- a/testchar.c 2013-04-17 10:50:30.250147418 +0200 | ||
208 | +++ b/testchar.c 2013-04-18 16:11:28.455733800 +0200 | ||
209 | @@ -23,7 +23,7 @@ | ||
210 | char document1[100] = "<doc>XXXX</doc>"; | ||
211 | char document2[100] = "<doc foo='XXXX'/>"; | ||
212 | |||
213 | -static void testDocumentRangeByte1(xmlParserCtxtPtr ctxt, char *document, | ||
214 | +static int testDocumentRangeByte1(xmlParserCtxtPtr ctxt, char *document, | ||
215 | int len, char *data, int forbid1, int forbid2) { | ||
216 | int i; | ||
217 | xmlDocPtr res; | ||
218 | @@ -37,33 +37,41 @@ | ||
219 | res = xmlReadMemory(document, len, "test", NULL, 0); | ||
220 | |||
221 | if ((i == forbid1) || (i == forbid2)) { | ||
222 | - if ((lastError == 0) || (res != NULL)) | ||
223 | + if ((lastError == 0) || (res != NULL)) { | ||
224 | fprintf(stderr, | ||
225 | "Failed to detect invalid char for Byte 0x%02X: %c\n", | ||
226 | i, i); | ||
227 | + return(1); | ||
228 | + } | ||
229 | } | ||
230 | |||
231 | else if ((i == '<') || (i == '&')) { | ||
232 | - if ((lastError == 0) || (res != NULL)) | ||
233 | + if ((lastError == 0) || (res != NULL)) { | ||
234 | fprintf(stderr, | ||
235 | "Failed to detect illegal char %c for Byte 0x%02X\n", i, i); | ||
236 | + return(1); | ||
237 | + } | ||
238 | } | ||
239 | else if (((i < 0x20) || (i >= 0x80)) && | ||
240 | (i != 0x9) && (i != 0xA) && (i != 0xD)) { | ||
241 | - if ((lastError != XML_ERR_INVALID_CHAR) && (res != NULL)) | ||
242 | + if ((lastError != XML_ERR_INVALID_CHAR) && (res != NULL)) { | ||
243 | fprintf(stderr, | ||
244 | "Failed to detect invalid char for Byte 0x%02X\n", i); | ||
245 | + return(1); | ||
246 | + } | ||
247 | } | ||
248 | else if (res == NULL) { | ||
249 | fprintf(stderr, | ||
250 | "Failed to parse valid char for Byte 0x%02X : %c\n", i, i); | ||
251 | + return(1); | ||
252 | } | ||
253 | if (res != NULL) | ||
254 | xmlFreeDoc(res); | ||
255 | } | ||
256 | + return(0); | ||
257 | } | ||
258 | |||
259 | -static void testDocumentRangeByte2(xmlParserCtxtPtr ctxt, char *document, | ||
260 | +static int testDocumentRangeByte2(xmlParserCtxtPtr ctxt, char *document, | ||
261 | int len, char *data) { | ||
262 | int i, j; | ||
263 | xmlDocPtr res; | ||
264 | @@ -80,10 +88,12 @@ | ||
265 | |||
266 | /* if first bit of first char is set, then second bit must too */ | ||
267 | if ((i & 0x80) && ((i & 0x40) == 0)) { | ||
268 | - if ((lastError == 0) || (res != NULL)) | ||
269 | + if ((lastError == 0) || (res != NULL)) { | ||
270 | fprintf(stderr, | ||
271 | "Failed to detect invalid char for Bytes 0x%02X 0x%02X\n", | ||
272 | i, j); | ||
273 | + return(1); | ||
274 | + } | ||
275 | } | ||
276 | |||
277 | /* | ||
278 | @@ -91,10 +101,12 @@ | ||
279 | * bits must be 10 | ||
280 | */ | ||
281 | else if ((i & 0x80) && ((j & 0xC0) != 0x80)) { | ||
282 | - if ((lastError == 0) || (res != NULL)) | ||
283 | + if ((lastError == 0) || (res != NULL)) { | ||
284 | fprintf(stderr, | ||
285 | "Failed to detect invalid char for Bytes 0x%02X 0x%02X\n", | ||
286 | i, j); | ||
287 | + return(1); | ||
288 | + } | ||
289 | } | ||
290 | |||
291 | /* | ||
292 | @@ -102,10 +114,12 @@ | ||
293 | * than 0x80, i.e. one of bits 5 to 1 of i must be set | ||
294 | */ | ||
295 | else if ((i & 0x80) && ((i & 0x1E) == 0)) { | ||
296 | - if ((lastError == 0) || (res != NULL)) | ||
297 | + if ((lastError == 0) || (res != NULL)) { | ||
298 | fprintf(stderr, | ||
299 | "Failed to detect invalid char for Bytes 0x%02X 0x%02X\n", | ||
300 | i, j); | ||
301 | + return(1); | ||
302 | + } | ||
303 | } | ||
304 | |||
305 | /* | ||
306 | @@ -113,10 +127,12 @@ | ||
307 | * at least 3 bytes, but we give only 2 ! | ||
308 | */ | ||
309 | else if ((i & 0xE0) == 0xE0) { | ||
310 | - if ((lastError == 0) || (res != NULL)) | ||
311 | + if ((lastError == 0) || (res != NULL)) { | ||
312 | fprintf(stderr, | ||
313 | "Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x00\n", | ||
314 | i, j); | ||
315 | + return(1); | ||
316 | + } | ||
317 | } | ||
318 | |||
319 | /* | ||
320 | @@ -125,11 +141,13 @@ | ||
321 | else if ((lastError != 0) || (res == NULL)) { | ||
322 | fprintf(stderr, | ||
323 | "Failed to parse document for Bytes 0x%02X 0x%02X\n", i, j); | ||
324 | + return(1); | ||
325 | } | ||
326 | if (res != NULL) | ||
327 | xmlFreeDoc(res); | ||
328 | } | ||
329 | } | ||
330 | + return(0); | ||
331 | } | ||
332 | |||
333 | /** | ||
334 | @@ -141,9 +159,10 @@ | ||
335 | * CDATA in text or in attribute values. | ||
336 | */ | ||
337 | |||
338 | -static void testDocumentRanges(void) { | ||
339 | +static int testDocumentRanges(void) { | ||
340 | xmlParserCtxtPtr ctxt; | ||
341 | char *data; | ||
342 | + int test_ret = 0; | ||
343 | |||
344 | /* | ||
345 | * Set up a parsing context using the first document as | ||
346 | @@ -152,7 +171,7 @@ | ||
347 | ctxt = xmlNewParserCtxt(); | ||
348 | if (ctxt == NULL) { | ||
349 | fprintf(stderr, "Failed to allocate parser context\n"); | ||
350 | - return; | ||
351 | + return(1); | ||
352 | } | ||
353 | |||
354 | printf("testing 1 byte char in document: 1"); | ||
355 | @@ -163,7 +182,7 @@ | ||
356 | data[2] = ' '; | ||
357 | data[3] = ' '; | ||
358 | /* test 1 byte injection at beginning of area */ | ||
359 | - testDocumentRangeByte1(ctxt, &document1[0], strlen(document1), | ||
360 | + test_ret += testDocumentRangeByte1(ctxt, &document1[0], strlen(document1), | ||
361 | data, -1, -1); | ||
362 | printf(" 2"); | ||
363 | fflush(stdout); | ||
364 | @@ -172,7 +191,7 @@ | ||
365 | data[2] = ' '; | ||
366 | data[3] = ' '; | ||
367 | /* test 1 byte injection at end of area */ | ||
368 | - testDocumentRangeByte1(ctxt, &document1[0], strlen(document1), | ||
369 | + test_ret += testDocumentRangeByte1(ctxt, &document1[0], strlen(document1), | ||
370 | data + 3, -1, -1); | ||
371 | |||
372 | printf(" 3"); | ||
373 | @@ -183,7 +202,7 @@ | ||
374 | data[2] = ' '; | ||
375 | data[3] = ' '; | ||
376 | /* test 1 byte injection at beginning of area */ | ||
377 | - testDocumentRangeByte1(ctxt, &document2[0], strlen(document2), | ||
378 | + test_ret += testDocumentRangeByte1(ctxt, &document2[0], strlen(document2), | ||
379 | data, '\'', -1); | ||
380 | printf(" 4"); | ||
381 | fflush(stdout); | ||
382 | @@ -192,7 +211,7 @@ | ||
383 | data[2] = ' '; | ||
384 | data[3] = ' '; | ||
385 | /* test 1 byte injection at end of area */ | ||
386 | - testDocumentRangeByte1(ctxt, &document2[0], strlen(document2), | ||
387 | + test_ret += testDocumentRangeByte1(ctxt, &document2[0], strlen(document2), | ||
388 | data + 3, '\'', -1); | ||
389 | printf(" done\n"); | ||
390 | |||
391 | @@ -204,7 +223,7 @@ | ||
392 | data[2] = ' '; | ||
393 | data[3] = ' '; | ||
394 | /* test 2 byte injection at beginning of area */ | ||
395 | - testDocumentRangeByte2(ctxt, &document1[0], strlen(document1), | ||
396 | + test_ret += testDocumentRangeByte2(ctxt, &document1[0], strlen(document1), | ||
397 | data); | ||
398 | printf(" 2"); | ||
399 | fflush(stdout); | ||
400 | @@ -213,7 +232,7 @@ | ||
401 | data[2] = ' '; | ||
402 | data[3] = ' '; | ||
403 | /* test 2 byte injection at end of area */ | ||
404 | - testDocumentRangeByte2(ctxt, &document1[0], strlen(document1), | ||
405 | + test_ret += testDocumentRangeByte2(ctxt, &document1[0], strlen(document1), | ||
406 | data + 2); | ||
407 | |||
408 | printf(" 3"); | ||
409 | @@ -224,7 +243,7 @@ | ||
410 | data[2] = ' '; | ||
411 | data[3] = ' '; | ||
412 | /* test 2 byte injection at beginning of area */ | ||
413 | - testDocumentRangeByte2(ctxt, &document2[0], strlen(document2), | ||
414 | + test_ret += testDocumentRangeByte2(ctxt, &document2[0], strlen(document2), | ||
415 | data); | ||
416 | printf(" 4"); | ||
417 | fflush(stdout); | ||
418 | @@ -233,14 +252,15 @@ | ||
419 | data[2] = ' '; | ||
420 | data[3] = ' '; | ||
421 | /* test 2 byte injection at end of area */ | ||
422 | - testDocumentRangeByte2(ctxt, &document2[0], strlen(document2), | ||
423 | + test_ret += testDocumentRangeByte2(ctxt, &document2[0], strlen(document2), | ||
424 | data + 2); | ||
425 | printf(" done\n"); | ||
426 | |||
427 | xmlFreeParserCtxt(ctxt); | ||
428 | + return(test_ret); | ||
429 | } | ||
430 | |||
431 | -static void testCharRangeByte1(xmlParserCtxtPtr ctxt, char *data) { | ||
432 | +static int testCharRangeByte1(xmlParserCtxtPtr ctxt, char *data) { | ||
433 | int i = 0; | ||
434 | int len, c; | ||
435 | |||
436 | @@ -255,19 +275,25 @@ | ||
437 | c = xmlCurrentChar(ctxt, &len); | ||
438 | if ((i == 0) || (i >= 0x80)) { | ||
439 | /* we must see an error there */ | ||
440 | - if (lastError != XML_ERR_INVALID_CHAR) | ||
441 | + if (lastError != XML_ERR_INVALID_CHAR) { | ||
442 | fprintf(stderr, | ||
443 | "Failed to detect invalid char for Byte 0x%02X\n", i); | ||
444 | + return(1); | ||
445 | + } | ||
446 | } else if (i == 0xD) { | ||
447 | - if ((c != 0xA) || (len != 1)) | ||
448 | + if ((c != 0xA) || (len != 1)) { | ||
449 | fprintf(stderr, "Failed to convert char for Byte 0x%02X\n", i); | ||
450 | + return(1); | ||
451 | + } | ||
452 | } else if ((c != i) || (len != 1)) { | ||
453 | fprintf(stderr, "Failed to parse char for Byte 0x%02X\n", i); | ||
454 | + return(1); | ||
455 | } | ||
456 | } | ||
457 | + return(0); | ||
458 | } | ||
459 | |||
460 | -static void testCharRangeByte2(xmlParserCtxtPtr ctxt, char *data) { | ||
461 | +static int testCharRangeByte2(xmlParserCtxtPtr ctxt, char *data) { | ||
462 | int i, j; | ||
463 | int len, c; | ||
464 | |||
465 | @@ -284,10 +310,12 @@ | ||
466 | |||
467 | /* if first bit of first char is set, then second bit must too */ | ||
468 | if ((i & 0x80) && ((i & 0x40) == 0)) { | ||
469 | - if (lastError != XML_ERR_INVALID_CHAR) | ||
470 | + if (lastError != XML_ERR_INVALID_CHAR) { | ||
471 | fprintf(stderr, | ||
472 | "Failed to detect invalid char for Bytes 0x%02X 0x%02X\n", | ||
473 | i, j); | ||
474 | + return(1); | ||
475 | + } | ||
476 | } | ||
477 | |||
478 | /* | ||
479 | @@ -295,10 +323,12 @@ | ||
480 | * bits must be 10 | ||
481 | */ | ||
482 | else if ((i & 0x80) && ((j & 0xC0) != 0x80)) { | ||
483 | - if (lastError != XML_ERR_INVALID_CHAR) | ||
484 | + if (lastError != XML_ERR_INVALID_CHAR) { | ||
485 | fprintf(stderr, | ||
486 | "Failed to detect invalid char for Bytes 0x%02X 0x%02X: %d\n", | ||
487 | i, j, c); | ||
488 | + return(1); | ||
489 | + } | ||
490 | } | ||
491 | |||
492 | /* | ||
493 | @@ -306,10 +336,12 @@ | ||
494 | * than 0x80, i.e. one of bits 5 to 1 of i must be set | ||
495 | */ | ||
496 | else if ((i & 0x80) && ((i & 0x1E) == 0)) { | ||
497 | - if (lastError != XML_ERR_INVALID_CHAR) | ||
498 | + if (lastError != XML_ERR_INVALID_CHAR) { | ||
499 | fprintf(stderr, | ||
500 | "Failed to detect invalid char for Bytes 0x%02X 0x%02X: %d\n", | ||
501 | i, j, c); | ||
502 | + return(1); | ||
503 | + } | ||
504 | } | ||
505 | |||
506 | /* | ||
507 | @@ -317,10 +349,12 @@ | ||
508 | * at least 3 bytes, but we give only 2 ! | ||
509 | */ | ||
510 | else if ((i & 0xE0) == 0xE0) { | ||
511 | - if (lastError != XML_ERR_INVALID_CHAR) | ||
512 | + if (lastError != XML_ERR_INVALID_CHAR) { | ||
513 | fprintf(stderr, | ||
514 | "Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x00\n", | ||
515 | i, j); | ||
516 | + return(1); | ||
517 | + } | ||
518 | } | ||
519 | |||
520 | /* | ||
521 | @@ -329,6 +363,7 @@ | ||
522 | else if ((lastError != 0) || (len != 2)) { | ||
523 | fprintf(stderr, | ||
524 | "Failed to parse char for Bytes 0x%02X 0x%02X\n", i, j); | ||
525 | + return(1); | ||
526 | } | ||
527 | |||
528 | /* | ||
529 | @@ -338,12 +373,14 @@ | ||
530 | fprintf(stderr, | ||
531 | "Failed to parse char for Bytes 0x%02X 0x%02X: expect %d got %d\n", | ||
532 | i, j, ((j & 0x3F) + ((i & 0x1F) << 6)), c); | ||
533 | + return(1); | ||
534 | } | ||
535 | } | ||
536 | } | ||
537 | + return(0); | ||
538 | } | ||
539 | |||
540 | -static void testCharRangeByte3(xmlParserCtxtPtr ctxt, char *data) { | ||
541 | +static int testCharRangeByte3(xmlParserCtxtPtr ctxt, char *data) { | ||
542 | int i, j, k, K; | ||
543 | int len, c; | ||
544 | unsigned char lows[6] = {0, 0x80, 0x81, 0xC1, 0xFF, 0xBF}; | ||
545 | @@ -368,20 +405,24 @@ | ||
546 | * at least 4 bytes, but we give only 3 ! | ||
547 | */ | ||
548 | if ((i & 0xF0) == 0xF0) { | ||
549 | - if (lastError != XML_ERR_INVALID_CHAR) | ||
550 | + if (lastError != XML_ERR_INVALID_CHAR) { | ||
551 | fprintf(stderr, | ||
552 | "Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x%02X 0x%02X\n", | ||
553 | i, j, K, data[3]); | ||
554 | + return(1); | ||
555 | + } | ||
556 | } | ||
557 | |||
558 | /* | ||
559 | * The second and the third bytes must start with 10 | ||
560 | */ | ||
561 | else if (((j & 0xC0) != 0x80) || ((K & 0xC0) != 0x80)) { | ||
562 | - if (lastError != XML_ERR_INVALID_CHAR) | ||
563 | + if (lastError != XML_ERR_INVALID_CHAR) { | ||
564 | fprintf(stderr, | ||
565 | "Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x%02X\n", | ||
566 | i, j, K); | ||
567 | + return(1); | ||
568 | + } | ||
569 | } | ||
570 | |||
571 | /* | ||
572 | @@ -390,10 +431,12 @@ | ||
573 | * the 6th byte of data[1] must be set | ||
574 | */ | ||
575 | else if (((i & 0xF) == 0) && ((j & 0x20) == 0)) { | ||
576 | - if (lastError != XML_ERR_INVALID_CHAR) | ||
577 | + if (lastError != XML_ERR_INVALID_CHAR) { | ||
578 | fprintf(stderr, | ||
579 | "Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x%02X\n", | ||
580 | i, j, K); | ||
581 | + return(1); | ||
582 | + } | ||
583 | } | ||
584 | |||
585 | /* | ||
586 | @@ -401,10 +444,12 @@ | ||
587 | */ | ||
588 | else if (((value > 0xD7FF) && (value <0xE000)) || | ||
589 | ((value > 0xFFFD) && (value <0x10000))) { | ||
590 | - if (lastError != XML_ERR_INVALID_CHAR) | ||
591 | + if (lastError != XML_ERR_INVALID_CHAR) { | ||
592 | fprintf(stderr, | ||
593 | "Failed to detect invalid char 0x%04X for Bytes 0x%02X 0x%02X 0x%02X\n", | ||
594 | value, i, j, K); | ||
595 | + return(1); | ||
596 | + } | ||
597 | } | ||
598 | |||
599 | /* | ||
600 | @@ -414,6 +459,7 @@ | ||
601 | fprintf(stderr, | ||
602 | "Failed to parse char for Bytes 0x%02X 0x%02X 0x%02X\n", | ||
603 | i, j, K); | ||
604 | + return(1); | ||
605 | } | ||
606 | |||
607 | /* | ||
608 | @@ -423,13 +469,15 @@ | ||
609 | fprintf(stderr, | ||
610 | "Failed to parse char for Bytes 0x%02X 0x%02X 0x%02X: expect %d got %d\n", | ||
611 | i, j, data[2], value, c); | ||
612 | + return(1); | ||
613 | } | ||
614 | } | ||
615 | } | ||
616 | } | ||
617 | + return(0); | ||
618 | } | ||
619 | |||
620 | -static void testCharRangeByte4(xmlParserCtxtPtr ctxt, char *data) { | ||
621 | +static int testCharRangeByte4(xmlParserCtxtPtr ctxt, char *data) { | ||
622 | int i, j, k, K, l, L; | ||
623 | int len, c; | ||
624 | unsigned char lows[6] = {0, 0x80, 0x81, 0xC1, 0xFF, 0xBF}; | ||
625 | @@ -458,10 +506,12 @@ | ||
626 | * at least 5 bytes, but we give only 4 ! | ||
627 | */ | ||
628 | if ((i & 0xF8) == 0xF8) { | ||
629 | - if (lastError != XML_ERR_INVALID_CHAR) | ||
630 | + if (lastError != XML_ERR_INVALID_CHAR) { | ||
631 | fprintf(stderr, | ||
632 | "Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x%02X 0x%02X\n", | ||
633 | i, j, K, data[3]); | ||
634 | + return(1); | ||
635 | + } | ||
636 | } | ||
637 | |||
638 | /* | ||
639 | @@ -469,10 +519,12 @@ | ||
640 | */ | ||
641 | else if (((j & 0xC0) != 0x80) || ((K & 0xC0) != 0x80) || | ||
642 | ((L & 0xC0) != 0x80)) { | ||
643 | - if (lastError != XML_ERR_INVALID_CHAR) | ||
644 | + if (lastError != XML_ERR_INVALID_CHAR) { | ||
645 | fprintf(stderr, | ||
646 | "Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x%02X 0x%02X\n", | ||
647 | i, j, K, L); | ||
648 | + return(1); | ||
649 | + } | ||
650 | } | ||
651 | |||
652 | /* | ||
653 | @@ -481,10 +533,12 @@ | ||
654 | * the 6 or 5th byte of j must be set | ||
655 | */ | ||
656 | else if (((i & 0x7) == 0) && ((j & 0x30) == 0)) { | ||
657 | - if (lastError != XML_ERR_INVALID_CHAR) | ||
658 | + if (lastError != XML_ERR_INVALID_CHAR) { | ||
659 | fprintf(stderr, | ||
660 | "Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x%02X 0x%02X\n", | ||
661 | i, j, K, L); | ||
662 | + return(1); | ||
663 | + } | ||
664 | } | ||
665 | |||
666 | /* | ||
667 | @@ -493,10 +547,12 @@ | ||
668 | else if (((value > 0xD7FF) && (value <0xE000)) || | ||
669 | ((value > 0xFFFD) && (value <0x10000)) || | ||
670 | (value > 0x10FFFF)) { | ||
671 | - if (lastError != XML_ERR_INVALID_CHAR) | ||
672 | + if (lastError != XML_ERR_INVALID_CHAR) { | ||
673 | fprintf(stderr, | ||
674 | "Failed to detect invalid char 0x%04X for Bytes 0x%02X 0x%02X 0x%02X 0x%02X\n", | ||
675 | value, i, j, K, L); | ||
676 | + return(1); | ||
677 | + } | ||
678 | } | ||
679 | |||
680 | /* | ||
681 | @@ -506,6 +562,7 @@ | ||
682 | fprintf(stderr, | ||
683 | "Failed to parse char for Bytes 0x%02X 0x%02X 0x%02X\n", | ||
684 | i, j, K); | ||
685 | + return(1); | ||
686 | } | ||
687 | |||
688 | /* | ||
689 | @@ -515,11 +572,13 @@ | ||
690 | fprintf(stderr, | ||
691 | "Failed to parse char for Bytes 0x%02X 0x%02X 0x%02X: expect %d got %d\n", | ||
692 | i, j, data[2], value, c); | ||
693 | + return(1); | ||
694 | } | ||
695 | } | ||
696 | } | ||
697 | } | ||
698 | } | ||
699 | + return(0); | ||
700 | } | ||
701 | |||
702 | /** | ||
703 | @@ -530,11 +589,12 @@ | ||
704 | * cover the full range of UTF-8 chars accepted by XML-1.0 | ||
705 | */ | ||
706 | |||
707 | -static void testCharRanges(void) { | ||
708 | +static int testCharRanges(void) { | ||
709 | char data[5]; | ||
710 | xmlParserCtxtPtr ctxt; | ||
711 | xmlParserInputBufferPtr buf; | ||
712 | xmlParserInputPtr input; | ||
713 | + int test_ret = 0; | ||
714 | |||
715 | memset(data, 0, 5); | ||
716 | |||
717 | @@ -545,17 +605,19 @@ | ||
718 | ctxt = xmlNewParserCtxt(); | ||
719 | if (ctxt == NULL) { | ||
720 | fprintf(stderr, "Failed to allocate parser context\n"); | ||
721 | - return; | ||
722 | + return(1); | ||
723 | } | ||
724 | buf = xmlParserInputBufferCreateStatic(data, sizeof(data), | ||
725 | XML_CHAR_ENCODING_NONE); | ||
726 | if (buf == NULL) { | ||
727 | fprintf(stderr, "Failed to allocate input buffer\n"); | ||
728 | + test_ret = 1; | ||
729 | goto error; | ||
730 | } | ||
731 | input = xmlNewInputStream(ctxt); | ||
732 | if (input == NULL) { | ||
733 | xmlFreeParserInputBuffer(buf); | ||
734 | + test_ret = 1; | ||
735 | goto error; | ||
736 | } | ||
737 | input->filename = NULL; | ||
738 | @@ -567,25 +629,28 @@ | ||
739 | |||
740 | printf("testing char range: 1"); | ||
741 | fflush(stdout); | ||
742 | - testCharRangeByte1(ctxt, data); | ||
743 | + test_ret += testCharRangeByte1(ctxt, data); | ||
744 | printf(" 2"); | ||
745 | fflush(stdout); | ||
746 | - testCharRangeByte2(ctxt, data); | ||
747 | + test_ret += testCharRangeByte2(ctxt, data); | ||
748 | printf(" 3"); | ||
749 | fflush(stdout); | ||
750 | - testCharRangeByte3(ctxt, data); | ||
751 | + test_ret += testCharRangeByte3(ctxt, data); | ||
752 | printf(" 4"); | ||
753 | fflush(stdout); | ||
754 | - testCharRangeByte4(ctxt, data); | ||
755 | + test_ret += testCharRangeByte4(ctxt, data); | ||
756 | printf(" done\n"); | ||
757 | fflush(stdout); | ||
758 | |||
759 | error: | ||
760 | xmlFreeParserCtxt(ctxt); | ||
761 | + return(test_ret); | ||
762 | } | ||
763 | |||
764 | int main(void) { | ||
765 | |||
766 | + int ret = 0; | ||
767 | + | ||
768 | /* | ||
769 | * this initialize the library and check potential ABI mismatches | ||
770 | * between the version it was compiled for and the actual shared | ||
771 | @@ -602,8 +667,9 @@ | ||
772 | /* | ||
773 | * Run the tests | ||
774 | */ | ||
775 | - testCharRanges(); | ||
776 | - testDocumentRanges(); | ||
777 | + ret += testCharRanges(); | ||
778 | + ret += testDocumentRanges(); | ||
779 | + printf("%s: testchar\n\n", (ret == 0) ? "PASS" : "FAIL"); | ||
780 | |||
781 | /* | ||
782 | * Cleanup function for the XML library. | ||
783 | diff -uNr a/testdict.c b/testdict.c | ||
784 | --- a/testdict.c 2013-04-16 15:08:42.971177193 +0200 | ||
785 | +++ b/testdict.c 2013-04-18 15:59:00.699482439 +0200 | ||
786 | @@ -440,5 +440,6 @@ | ||
787 | clean_strings(); | ||
788 | xmlCleanupParser(); | ||
789 | xmlMemoryDump(); | ||
790 | + printf("%s: testdict\n\n", (ret == 0) ? "PASS" : "FAIL"); | ||
791 | return(ret); | ||
792 | } | ||
793 | diff -uNr a/testlimits.c b/testlimits.c | ||
794 | --- a/testlimits.c 2013-04-12 16:16:36.180354177 +0200 | ||
795 | +++ b/testlimits.c 2013-04-17 14:03:17.203092987 +0200 | ||
796 | @@ -1630,5 +1630,6 @@ | ||
797 | xmlCleanupParser(); | ||
798 | xmlMemoryDump(); | ||
799 | |||
800 | + printf("%s: testlimits\n", (ret == 0) ? "PASS" : "FAIL"); | ||
801 | return(ret); | ||
802 | } | ||
803 | diff -uNr a/testrecurse.c b/testrecurse.c | ||
804 | --- a/testrecurse.c 2013-04-16 13:19:49.366536295 +0200 | ||
805 | +++ b/testrecurse.c 2013-04-17 14:06:27.367091622 +0200 | ||
806 | @@ -892,6 +892,7 @@ | ||
807 | err++; | ||
808 | } | ||
809 | } | ||
810 | + printf("%s: %s\n", (err == 0) ? "PASS" : "FAIL", tst->desc); | ||
811 | return(err); | ||
812 | } | ||
813 | |||
814 | @@ -961,5 +962,6 @@ | ||
815 | xmlCleanupParser(); | ||
816 | xmlMemoryDump(); | ||
817 | |||
818 | + printf("%s: testrecurse\n\n", (ret == 0) ? "PASS" : "FAIL"); | ||
819 | return(ret); | ||
820 | } | ||