nokogiri 1.6.7.2 → 1.6.8.rc1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of nokogiri might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.travis.yml +12 -9
- data/CHANGELOG.ja.rdoc +18 -0
- data/CHANGELOG.rdoc +12 -7
- data/CONTRIBUTING.md +42 -0
- data/Gemfile +1 -1
- data/Manifest.txt +6 -0
- data/README.md +1 -1
- data/Rakefile +1 -1
- data/bin/nokogiri +2 -2
- data/dependencies.yml +1 -1
- data/ext/nokogiri/extconf.rb +3 -3
- data/ext/nokogiri/nokogiri.c +0 -7
- data/ext/nokogiri/nokogiri.h +1 -34
- data/ext/nokogiri/xml_document.c +2 -4
- data/ext/nokogiri/xml_namespace.c +56 -17
- data/ext/nokogiri/xml_node.c +12 -36
- data/ext/nokogiri/xml_node_set.c +169 -143
- data/ext/nokogiri/xml_node_set.h +3 -4
- data/ext/nokogiri/xml_sax_parser.c +2 -5
- data/ext/nokogiri/xml_syntax_error.c +0 -4
- data/ext/nokogiri/xml_syntax_error.h +0 -1
- data/ext/nokogiri/xml_xpath_context.c +9 -18
- data/lib/nokogiri.rb +3 -0
- data/lib/nokogiri/css/parser.rb +8 -2
- data/lib/nokogiri/css/parser.y +7 -2
- data/lib/nokogiri/version.rb +1 -1
- data/lib/nokogiri/xml/document.rb +7 -1
- data/lib/nokogiri/xml/dtd.rb +4 -4
- data/lib/nokogiri/xml/node.rb +2 -2
- data/ports/archives/libxml2-2.9.3.tar.gz +0 -0
- data/test/css/test_parser.rb +7 -1
- data/test/files/GH_1042.html +18 -0
- data/test/files/namespace_pressure_test.xml +1684 -0
- data/test/files/tlm.html +2 -1
- data/test/html/sax/test_parser.rb +2 -2
- data/test/html/test_document.rb +18 -8
- data/test/html/test_document_encoding.rb +46 -54
- data/test/html/test_document_fragment.rb +21 -22
- data/test/html/test_node.rb +16 -0
- data/test/html/test_node_encoding.rb +12 -14
- data/test/namespaces/test_namespaces_in_parsed_doc.rb +14 -0
- data/test/test_reader.rb +19 -0
- data/test/test_xslt_transforms.rb +5 -3
- data/test/xml/sax/test_parser.rb +36 -39
- data/test/xml/test_document.rb +7 -2
- data/test/xml/test_document_encoding.rb +14 -16
- data/test/xml/test_dtd_encoding.rb +0 -2
- data/test/xml/test_node_encoding.rb +78 -80
- data/test/xml/test_reader_encoding.rb +100 -102
- data/test/xslt/test_exception_handling.rb +1 -1
- metadata +11 -28
- data/patches/libxml2/0001-Revert-Missing-initialization-for-the-catalog-module.patch +0 -29
- data/patches/libxml2/0002-Fix-missing-entities-after-CVE-2014-3660-fix.patch +0 -31
- data/patches/libxml2/0003-Stop-parsing-on-entities-boundaries-errors.patch +0 -32
- data/patches/libxml2/0004-Cleanup-conditional-section-error-handling.patch +0 -49
- data/patches/libxml2/0005-CVE-2015-1819-Enforce-the-reader-to-run-in-constant-.patch +0 -177
- data/patches/libxml2/0006-Another-variation-of-overflow-in-Conditional-section.patch +0 -32
- data/patches/libxml2/0007-Fix-an-error-in-previous-Conditional-section-patch.patch +0 -28
- data/patches/libxml2/0008-CVE-2015-8035-Fix-XZ-compression-support-loop.patch +0 -31
- data/patches/libxml2/0009-Updated-config.guess.patch +0 -397
- data/patches/libxml2/0010-Fix-parsering-short-unclosed-comment-uninitialized-access.patch +0 -64
- data/patches/libxml2/0011-Avoid-extra-processing-of-MarkupDecl-when-EOF.patch +0 -35
- data/patches/libxml2/0012-Avoid-processing-entities-after-encoding-conversion-.patch +0 -83
- data/patches/libxml2/0013-CVE-2015-7497-Avoid-an-heap-buffer-overflow-in-xmlDi.patch +0 -33
- data/patches/libxml2/0014-CVE-2015-5312-Another-entity-expansion-issue.patch +0 -32
- data/patches/libxml2/0015-Add-xmlHaltParser-to-stop-the-parser.patch +0 -81
- data/patches/libxml2/0016-Detect-incoherency-on-GROW.patch +0 -36
- data/patches/libxml2/0017-CVE-2015-7500-Fix-memory-access-error-due-to-incorre.patch +0 -105
- data/patches/libxml2/0018-CVE-2015-8242-Buffer-overead-with-HTML-parser-in-pus.patch +0 -43
- data/patches/libxml2/0019-Do-not-print-error-context-when-there-is-none.patch +0 -28
- data/patches/libxml2/0020-xmlStopParser-reset-errNo.patch +0 -41
- data/patches/libxml2/0021-Reuse-xmlHaltParser-where-it-makes-sense.patch +0 -175
- data/ports/archives/libxml2-2.9.2.tar.gz +0 -0
@@ -28,7 +28,7 @@ EOXSL
|
|
28
28
|
xsl.transform xml
|
29
29
|
fail('It should not get here')
|
30
30
|
rescue RuntimeError => e
|
31
|
-
assert_match(/
|
31
|
+
assert_match(/Can't have more than one root/, e.to_s, 'The exception message does not contain the expected information')
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nokogiri
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.8.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Patterson
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date:
|
15
|
+
date: 2015-12-17 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: mini_portile2
|
@@ -20,14 +20,14 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - "~>"
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 2.0.0
|
23
|
+
version: 2.0.0
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
27
27
|
requirements:
|
28
28
|
- - "~>"
|
29
29
|
- !ruby/object:Gem::Version
|
30
|
-
version: 2.0.0
|
30
|
+
version: 2.0.0
|
31
31
|
- !ruby/object:Gem::Dependency
|
32
32
|
name: rdoc
|
33
33
|
requirement: !ruby/object:Gem::Requirement
|
@@ -216,6 +216,7 @@ extensions:
|
|
216
216
|
extra_rdoc_files:
|
217
217
|
- CHANGELOG.ja.rdoc
|
218
218
|
- CHANGELOG.rdoc
|
219
|
+
- CONTRIBUTING.md
|
219
220
|
- C_CODING_STYLE.rdoc
|
220
221
|
- LICENSE.txt
|
221
222
|
- Manifest.txt
|
@@ -266,6 +267,7 @@ files:
|
|
266
267
|
- ".travis.yml"
|
267
268
|
- CHANGELOG.ja.rdoc
|
268
269
|
- CHANGELOG.rdoc
|
270
|
+
- CONTRIBUTING.md
|
269
271
|
- C_CODING_STYLE.rdoc
|
270
272
|
- Gemfile
|
271
273
|
- LICENSE.txt
|
@@ -411,27 +413,6 @@ files:
|
|
411
413
|
- lib/nokogiri/xslt.rb
|
412
414
|
- lib/nokogiri/xslt/stylesheet.rb
|
413
415
|
- lib/xsd/xmlparser/nokogiri.rb
|
414
|
-
- patches/libxml2/0001-Revert-Missing-initialization-for-the-catalog-module.patch
|
415
|
-
- patches/libxml2/0002-Fix-missing-entities-after-CVE-2014-3660-fix.patch
|
416
|
-
- patches/libxml2/0003-Stop-parsing-on-entities-boundaries-errors.patch
|
417
|
-
- patches/libxml2/0004-Cleanup-conditional-section-error-handling.patch
|
418
|
-
- patches/libxml2/0005-CVE-2015-1819-Enforce-the-reader-to-run-in-constant-.patch
|
419
|
-
- patches/libxml2/0006-Another-variation-of-overflow-in-Conditional-section.patch
|
420
|
-
- patches/libxml2/0007-Fix-an-error-in-previous-Conditional-section-patch.patch
|
421
|
-
- patches/libxml2/0008-CVE-2015-8035-Fix-XZ-compression-support-loop.patch
|
422
|
-
- patches/libxml2/0009-Updated-config.guess.patch
|
423
|
-
- patches/libxml2/0010-Fix-parsering-short-unclosed-comment-uninitialized-access.patch
|
424
|
-
- patches/libxml2/0011-Avoid-extra-processing-of-MarkupDecl-when-EOF.patch
|
425
|
-
- patches/libxml2/0012-Avoid-processing-entities-after-encoding-conversion-.patch
|
426
|
-
- patches/libxml2/0013-CVE-2015-7497-Avoid-an-heap-buffer-overflow-in-xmlDi.patch
|
427
|
-
- patches/libxml2/0014-CVE-2015-5312-Another-entity-expansion-issue.patch
|
428
|
-
- patches/libxml2/0015-Add-xmlHaltParser-to-stop-the-parser.patch
|
429
|
-
- patches/libxml2/0016-Detect-incoherency-on-GROW.patch
|
430
|
-
- patches/libxml2/0017-CVE-2015-7500-Fix-memory-access-error-due-to-incorre.patch
|
431
|
-
- patches/libxml2/0018-CVE-2015-8242-Buffer-overead-with-HTML-parser-in-pus.patch
|
432
|
-
- patches/libxml2/0019-Do-not-print-error-context-when-there-is-none.patch
|
433
|
-
- patches/libxml2/0020-xmlStopParser-reset-errNo.patch
|
434
|
-
- patches/libxml2/0021-Reuse-xmlHaltParser-where-it-makes-sense.patch
|
435
416
|
- patches/libxslt/0001-Adding-doc-update-related-to-1.1.28.patch
|
436
417
|
- patches/libxslt/0002-Fix-a-couple-of-places-where-f-printf-parameters-wer.patch
|
437
418
|
- patches/libxslt/0003-Initialize-pseudo-random-number-generator-with-curre.patch
|
@@ -447,7 +428,7 @@ files:
|
|
447
428
|
- patches/libxslt/0016-Fix-for-type-confusion-in-preprocessing-attributes.patch
|
448
429
|
- patches/libxslt/0017-Updated-config.guess.patch
|
449
430
|
- patches/sort-patches-by-date
|
450
|
-
- ports/archives/libxml2-2.9.
|
431
|
+
- ports/archives/libxml2-2.9.3.tar.gz
|
451
432
|
- ports/archives/libxslt-1.1.28.tar.gz
|
452
433
|
- suppressions/README.txt
|
453
434
|
- suppressions/nokogiri_ree-1.8.7.358.supp
|
@@ -461,6 +442,7 @@ files:
|
|
461
442
|
- test/css/test_xpath_visitor.rb
|
462
443
|
- test/decorators/test_slop.rb
|
463
444
|
- test/files/2ch.html
|
445
|
+
- test/files/GH_1042.html
|
464
446
|
- test/files/address_book.rlx
|
465
447
|
- test/files/address_book.xml
|
466
448
|
- test/files/atom.xml
|
@@ -473,6 +455,7 @@ files:
|
|
473
455
|
- test/files/exslt.xslt
|
474
456
|
- test/files/foo/foo.xsd
|
475
457
|
- test/files/metacharset.html
|
458
|
+
- test/files/namespace_pressure_test.xml
|
476
459
|
- test/files/noencoding.html
|
477
460
|
- test/files/po.xml
|
478
461
|
- test/files/po.xsd
|
@@ -579,9 +562,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
579
562
|
version: 1.9.2
|
580
563
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
581
564
|
requirements:
|
582
|
-
- - "
|
565
|
+
- - ">"
|
583
566
|
- !ruby/object:Gem::Version
|
584
|
-
version:
|
567
|
+
version: 1.3.1
|
585
568
|
requirements: []
|
586
569
|
rubyforge_project:
|
587
570
|
rubygems_version: 2.4.8
|
@@ -1,29 +0,0 @@
|
|
1
|
-
From f65128f38289d77ff322d63aef2858cc0a819c34 Mon Sep 17 00:00:00 2001
|
2
|
-
From: Daniel Veillard <veillard@redhat.com>
|
3
|
-
Date: Fri, 17 Oct 2014 17:13:41 +0800
|
4
|
-
Subject: [PATCH] Revert "Missing initialization for the catalog module"
|
5
|
-
|
6
|
-
This reverts commit 054c716ea1bf001544127a4ab4f4346d1b9947e7.
|
7
|
-
As this break xmlcatalog command
|
8
|
-
https://bugzilla.redhat.com/show_bug.cgi?id=1153753
|
9
|
-
---
|
10
|
-
parser.c | 3 ---
|
11
|
-
1 file changed, 3 deletions(-)
|
12
|
-
|
13
|
-
diff --git a/parser.c b/parser.c
|
14
|
-
index 1d93967..67c9dfd 100644
|
15
|
-
--- a/parser.c
|
16
|
-
+++ b/parser.c
|
17
|
-
@@ -14830,9 +14830,6 @@ xmlInitParser(void) {
|
18
|
-
#ifdef LIBXML_XPATH_ENABLED
|
19
|
-
xmlXPathInit();
|
20
|
-
#endif
|
21
|
-
-#ifdef LIBXML_CATALOG_ENABLED
|
22
|
-
- xmlInitializeCatalog();
|
23
|
-
-#endif
|
24
|
-
xmlParserInitialized = 1;
|
25
|
-
#ifdef LIBXML_THREAD_ENABLED
|
26
|
-
}
|
27
|
-
--
|
28
|
-
2.1.2
|
29
|
-
|
@@ -1,31 +0,0 @@
|
|
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: [PATCH] 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
|
-
parser.c | 3 ++-
|
13
|
-
1 file changed, 2 insertions(+), 1 deletion(-)
|
14
|
-
|
15
|
-
diff --git a/parser.c b/parser.c
|
16
|
-
index 67c9dfd..a8d1b67 100644
|
17
|
-
--- a/parser.c
|
18
|
-
+++ b/parser.c
|
19
|
-
@@ -7235,7 +7235,8 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
|
20
|
-
* far more secure as the parser will only process data coming from
|
21
|
-
* the document entity by default.
|
22
|
-
*/
|
23
|
-
- if ((ent->checked == 0) &&
|
24
|
-
+ if (((ent->checked == 0) ||
|
25
|
-
+ ((ent->children == NULL) && (ctxt->options & XML_PARSE_NOENT))) &&
|
26
|
-
((ent->etype != XML_EXTERNAL_GENERAL_PARSED_ENTITY) ||
|
27
|
-
(ctxt->options & (XML_PARSE_NOENT | XML_PARSE_DTDVALID)))) {
|
28
|
-
unsigned long oldnbent = ctxt->nbentities;
|
29
|
-
--
|
30
|
-
2.1.2
|
31
|
-
|
@@ -1,32 +0,0 @@
|
|
1
|
-
From 99d99063ae5c4b6bd2b58324273401f3ce42a550 Mon Sep 17 00:00:00 2001
|
2
|
-
From: Daniel Veillard <veillard@redhat.com>
|
3
|
-
Date: Mon, 23 Feb 2015 11:17:35 +0800
|
4
|
-
Subject: [PATCH 3/8] Stop parsing on entities boundaries errors
|
5
|
-
|
6
|
-
For https://bugzilla.gnome.org/show_bug.cgi?id=744980
|
7
|
-
|
8
|
-
There are times, like on unterminated entities that it's preferable to
|
9
|
-
stop parsing, even if that means less error reporting. Entities are
|
10
|
-
feeding the parser on further processing, and if they are ill defined
|
11
|
-
then it's possible to get the parser to bug. Also do the same on
|
12
|
-
Conditional Sections if the input is broken, as the structure of
|
13
|
-
the document can't be guessed.
|
14
|
-
---
|
15
|
-
parser.c | 1 +
|
16
|
-
1 file changed, 1 insertion(+)
|
17
|
-
|
18
|
-
diff --git a/parser.c b/parser.c
|
19
|
-
index 1d93967..7b0380c 100644
|
20
|
-
--- a/parser.c
|
21
|
-
+++ b/parser.c
|
22
|
-
@@ -5658,6 +5658,7 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) {
|
23
|
-
if (RAW != '>') {
|
24
|
-
xmlFatalErrMsgStr(ctxt, XML_ERR_ENTITY_NOT_FINISHED,
|
25
|
-
"xmlParseEntityDecl: entity %s not terminated\n", name);
|
26
|
-
+ xmlStopParser(ctxt);
|
27
|
-
} else {
|
28
|
-
if (input != ctxt->input) {
|
29
|
-
xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
|
30
|
-
--
|
31
|
-
2.5.0
|
32
|
-
|
@@ -1,49 +0,0 @@
|
|
1
|
-
From c8d3950c5532c2e3d954bacdb8c479bb9fdacf89 Mon Sep 17 00:00:00 2001
|
2
|
-
From: Daniel Veillard <veillard@redhat.com>
|
3
|
-
Date: Mon, 23 Feb 2015 11:29:20 +0800
|
4
|
-
Subject: [PATCH 4/8] Cleanup conditional section error handling
|
5
|
-
|
6
|
-
For https://bugzilla.gnome.org/show_bug.cgi?id=744980
|
7
|
-
|
8
|
-
The error handling of Conditional Section also need to be
|
9
|
-
straightened as the structure of the document can't be
|
10
|
-
guessed on a failure there and it's better to stop parsing
|
11
|
-
as further errors are likely to be irrelevant.
|
12
|
-
---
|
13
|
-
parser.c | 6 ++++++
|
14
|
-
1 file changed, 6 insertions(+)
|
15
|
-
|
16
|
-
diff --git a/parser.c b/parser.c
|
17
|
-
index 7b0380c..1e714e7 100644
|
18
|
-
--- a/parser.c
|
19
|
-
+++ b/parser.c
|
20
|
-
@@ -6770,6 +6770,8 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
|
21
|
-
SKIP_BLANKS;
|
22
|
-
if (RAW != '[') {
|
23
|
-
xmlFatalErr(ctxt, XML_ERR_CONDSEC_INVALID, NULL);
|
24
|
-
+ xmlStopParser(ctxt);
|
25
|
-
+ return;
|
26
|
-
} else {
|
27
|
-
if (ctxt->input->id != id) {
|
28
|
-
xmlValidityError(ctxt, XML_ERR_ENTITY_BOUNDARY,
|
29
|
-
@@ -6830,6 +6832,8 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
|
30
|
-
SKIP_BLANKS;
|
31
|
-
if (RAW != '[') {
|
32
|
-
xmlFatalErr(ctxt, XML_ERR_CONDSEC_INVALID, NULL);
|
33
|
-
+ xmlStopParser(ctxt);
|
34
|
-
+ return;
|
35
|
-
} else {
|
36
|
-
if (ctxt->input->id != id) {
|
37
|
-
xmlValidityError(ctxt, XML_ERR_ENTITY_BOUNDARY,
|
38
|
-
@@ -6885,6 +6889,8 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
|
39
|
-
|
40
|
-
} else {
|
41
|
-
xmlFatalErr(ctxt, XML_ERR_CONDSEC_INVALID_KEYWORD, NULL);
|
42
|
-
+ xmlStopParser(ctxt);
|
43
|
-
+ return;
|
44
|
-
}
|
45
|
-
|
46
|
-
if (RAW == 0)
|
47
|
-
--
|
48
|
-
2.5.0
|
49
|
-
|
@@ -1,177 +0,0 @@
|
|
1
|
-
From 12f31177b0d9be57ed8fb3467b501606fb145286 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 5/8] CVE-2015-1819 Enforce the reader to run in constant
|
5
|
-
memory
|
6
|
-
|
7
|
-
One of the operation on the reader could resolve entities
|
8
|
-
leading to the classic expansion issue. Make sure the
|
9
|
-
buffer used for xmlreader operation is bounded.
|
10
|
-
Introduce a new allocation type for the buffers for this effect.
|
11
|
-
---
|
12
|
-
buf.c | 43 ++++++++++++++++++++++++++++++++++++++++++-
|
13
|
-
include/libxml/tree.h | 3 ++-
|
14
|
-
xmlreader.c | 20 +++++++++++++++++++-
|
15
|
-
3 files changed, 63 insertions(+), 3 deletions(-)
|
16
|
-
|
17
|
-
diff --git a/buf.c b/buf.c
|
18
|
-
index 6efc7b6..07922ff 100644
|
19
|
-
--- a/buf.c
|
20
|
-
+++ b/buf.c
|
21
|
-
@@ -27,6 +27,7 @@
|
22
|
-
#include <libxml/tree.h>
|
23
|
-
#include <libxml/globals.h>
|
24
|
-
#include <libxml/tree.h>
|
25
|
-
+#include <libxml/parserInternals.h> /* for XML_MAX_TEXT_LENGTH */
|
26
|
-
#include "buf.h"
|
27
|
-
|
28
|
-
#define WITH_BUFFER_COMPAT
|
29
|
-
@@ -299,7 +300,8 @@ xmlBufSetAllocationScheme(xmlBufPtr buf,
|
30
|
-
if ((scheme == XML_BUFFER_ALLOC_DOUBLEIT) ||
|
31
|
-
(scheme == XML_BUFFER_ALLOC_EXACT) ||
|
32
|
-
(scheme == XML_BUFFER_ALLOC_HYBRID) ||
|
33
|
-
- (scheme == XML_BUFFER_ALLOC_IMMUTABLE)) {
|
34
|
-
+ (scheme == XML_BUFFER_ALLOC_IMMUTABLE) ||
|
35
|
-
+ (scheme == XML_BUFFER_ALLOC_BOUNDED)) {
|
36
|
-
buf->alloc = scheme;
|
37
|
-
if (buf->buffer)
|
38
|
-
buf->buffer->alloc = scheme;
|
39
|
-
@@ -458,6 +460,18 @@ xmlBufGrowInternal(xmlBufPtr buf, size_t len) {
|
40
|
-
size = buf->use + len + 100;
|
41
|
-
#endif
|
42
|
-
|
43
|
-
+ if (buf->alloc == XML_BUFFER_ALLOC_BOUNDED) {
|
44
|
-
+ /*
|
45
|
-
+ * Used to provide parsing limits
|
46
|
-
+ */
|
47
|
-
+ if ((buf->use + len >= XML_MAX_TEXT_LENGTH) ||
|
48
|
-
+ (buf->size >= XML_MAX_TEXT_LENGTH)) {
|
49
|
-
+ xmlBufMemoryError(buf, "buffer error: text too long\n");
|
50
|
-
+ return(0);
|
51
|
-
+ }
|
52
|
-
+ if (size >= XML_MAX_TEXT_LENGTH)
|
53
|
-
+ size = XML_MAX_TEXT_LENGTH;
|
54
|
-
+ }
|
55
|
-
if ((buf->alloc == XML_BUFFER_ALLOC_IO) && (buf->contentIO != NULL)) {
|
56
|
-
size_t start_buf = buf->content - buf->contentIO;
|
57
|
-
|
58
|
-
@@ -739,6 +753,15 @@ xmlBufResize(xmlBufPtr buf, size_t size)
|
59
|
-
CHECK_COMPAT(buf)
|
60
|
-
|
61
|
-
if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return(0);
|
62
|
-
+ if (buf->alloc == XML_BUFFER_ALLOC_BOUNDED) {
|
63
|
-
+ /*
|
64
|
-
+ * Used to provide parsing limits
|
65
|
-
+ */
|
66
|
-
+ if (size >= XML_MAX_TEXT_LENGTH) {
|
67
|
-
+ xmlBufMemoryError(buf, "buffer error: text too long\n");
|
68
|
-
+ return(0);
|
69
|
-
+ }
|
70
|
-
+ }
|
71
|
-
|
72
|
-
/* Don't resize if we don't have to */
|
73
|
-
if (size < buf->size)
|
74
|
-
@@ -867,6 +890,15 @@ xmlBufAdd(xmlBufPtr buf, const xmlChar *str, int len) {
|
75
|
-
|
76
|
-
needSize = buf->use + len + 2;
|
77
|
-
if (needSize > buf->size){
|
78
|
-
+ if (buf->alloc == XML_BUFFER_ALLOC_BOUNDED) {
|
79
|
-
+ /*
|
80
|
-
+ * Used to provide parsing limits
|
81
|
-
+ */
|
82
|
-
+ if (needSize >= XML_MAX_TEXT_LENGTH) {
|
83
|
-
+ xmlBufMemoryError(buf, "buffer error: text too long\n");
|
84
|
-
+ return(-1);
|
85
|
-
+ }
|
86
|
-
+ }
|
87
|
-
if (!xmlBufResize(buf, needSize)){
|
88
|
-
xmlBufMemoryError(buf, "growing buffer");
|
89
|
-
return XML_ERR_NO_MEMORY;
|
90
|
-
@@ -938,6 +970,15 @@ xmlBufAddHead(xmlBufPtr buf, const xmlChar *str, int len) {
|
91
|
-
}
|
92
|
-
needSize = buf->use + len + 2;
|
93
|
-
if (needSize > buf->size){
|
94
|
-
+ if (buf->alloc == XML_BUFFER_ALLOC_BOUNDED) {
|
95
|
-
+ /*
|
96
|
-
+ * Used to provide parsing limits
|
97
|
-
+ */
|
98
|
-
+ if (needSize >= XML_MAX_TEXT_LENGTH) {
|
99
|
-
+ xmlBufMemoryError(buf, "buffer error: text too long\n");
|
100
|
-
+ return(-1);
|
101
|
-
+ }
|
102
|
-
+ }
|
103
|
-
if (!xmlBufResize(buf, needSize)){
|
104
|
-
xmlBufMemoryError(buf, "growing buffer");
|
105
|
-
return XML_ERR_NO_MEMORY;
|
106
|
-
diff --git a/include/libxml/tree.h b/include/libxml/tree.h
|
107
|
-
index 2f90717..4a9b3bc 100644
|
108
|
-
--- a/include/libxml/tree.h
|
109
|
-
+++ b/include/libxml/tree.h
|
110
|
-
@@ -76,7 +76,8 @@ typedef enum {
|
111
|
-
XML_BUFFER_ALLOC_EXACT, /* grow only to the minimal size */
|
112
|
-
XML_BUFFER_ALLOC_IMMUTABLE, /* immutable buffer */
|
113
|
-
XML_BUFFER_ALLOC_IO, /* special allocation scheme used for I/O */
|
114
|
-
- XML_BUFFER_ALLOC_HYBRID /* exact up to a threshold, and doubleit thereafter */
|
115
|
-
+ XML_BUFFER_ALLOC_HYBRID, /* exact up to a threshold, and doubleit thereafter */
|
116
|
-
+ XML_BUFFER_ALLOC_BOUNDED /* limit the upper size of the buffer */
|
117
|
-
} xmlBufferAllocationScheme;
|
118
|
-
|
119
|
-
/**
|
120
|
-
diff --git a/xmlreader.c b/xmlreader.c
|
121
|
-
index f19e123..471e7e2 100644
|
122
|
-
--- a/xmlreader.c
|
123
|
-
+++ b/xmlreader.c
|
124
|
-
@@ -2091,6 +2091,9 @@ xmlNewTextReader(xmlParserInputBufferPtr input, const char *URI) {
|
125
|
-
"xmlNewTextReader : malloc failed\n");
|
126
|
-
return(NULL);
|
127
|
-
}
|
128
|
-
+ /* no operation on a reader should require a huge buffer */
|
129
|
-
+ xmlBufSetAllocationScheme(ret->buffer,
|
130
|
-
+ XML_BUFFER_ALLOC_BOUNDED);
|
131
|
-
ret->sax = (xmlSAXHandler *) xmlMalloc(sizeof(xmlSAXHandler));
|
132
|
-
if (ret->sax == NULL) {
|
133
|
-
xmlBufFree(ret->buffer);
|
134
|
-
@@ -3616,6 +3619,7 @@ xmlTextReaderConstValue(xmlTextReaderPtr reader) {
|
135
|
-
return(((xmlNsPtr) node)->href);
|
136
|
-
case XML_ATTRIBUTE_NODE:{
|
137
|
-
xmlAttrPtr attr = (xmlAttrPtr) node;
|
138
|
-
+ const xmlChar *ret;
|
139
|
-
|
140
|
-
if ((attr->children != NULL) &&
|
141
|
-
(attr->children->type == XML_TEXT_NODE) &&
|
142
|
-
@@ -3629,10 +3633,21 @@ xmlTextReaderConstValue(xmlTextReaderPtr reader) {
|
143
|
-
"xmlTextReaderSetup : malloc failed\n");
|
144
|
-
return (NULL);
|
145
|
-
}
|
146
|
-
+ xmlBufSetAllocationScheme(reader->buffer,
|
147
|
-
+ XML_BUFFER_ALLOC_BOUNDED);
|
148
|
-
} else
|
149
|
-
xmlBufEmpty(reader->buffer);
|
150
|
-
xmlBufGetNodeContent(reader->buffer, node);
|
151
|
-
- return(xmlBufContent(reader->buffer));
|
152
|
-
+ ret = xmlBufContent(reader->buffer);
|
153
|
-
+ if (ret == NULL) {
|
154
|
-
+ /* error on the buffer best to reallocate */
|
155
|
-
+ xmlBufFree(reader->buffer);
|
156
|
-
+ reader->buffer = xmlBufCreateSize(100);
|
157
|
-
+ xmlBufSetAllocationScheme(reader->buffer,
|
158
|
-
+ XML_BUFFER_ALLOC_BOUNDED);
|
159
|
-
+ ret = BAD_CAST "";
|
160
|
-
+ }
|
161
|
-
+ return(ret);
|
162
|
-
}
|
163
|
-
break;
|
164
|
-
}
|
165
|
-
@@ -5131,6 +5146,9 @@ xmlTextReaderSetup(xmlTextReaderPtr reader,
|
166
|
-
"xmlTextReaderSetup : malloc failed\n");
|
167
|
-
return (-1);
|
168
|
-
}
|
169
|
-
+ /* no operation on a reader should require a huge buffer */
|
170
|
-
+ xmlBufSetAllocationScheme(reader->buffer,
|
171
|
-
+ XML_BUFFER_ALLOC_BOUNDED);
|
172
|
-
if (reader->sax == NULL)
|
173
|
-
reader->sax = (xmlSAXHandler *) xmlMalloc(sizeof(xmlSAXHandler));
|
174
|
-
if (reader->sax == NULL) {
|
175
|
-
--
|
176
|
-
2.5.0
|
177
|
-
|
@@ -1,32 +0,0 @@
|
|
1
|
-
From 9ee30e69f63379b3caf451aa7ae4058a1fa2fa73 Mon Sep 17 00:00:00 2001
|
2
|
-
From: Daniel Veillard <veillard@redhat.com>
|
3
|
-
Date: Fri, 23 Oct 2015 19:02:28 +0800
|
4
|
-
Subject: [PATCH 6/8] Another variation of overflow in Conditional sections
|
5
|
-
|
6
|
-
Which happen after the previous fix to
|
7
|
-
https://bugzilla.gnome.org/show_bug.cgi?id=756456
|
8
|
-
|
9
|
-
But stopping the parser and exiting we didn't pop the intermediary entities
|
10
|
-
and doing the SKIP there applies on an input which may be too small
|
11
|
-
---
|
12
|
-
parser.c | 4 +++-
|
13
|
-
1 file changed, 3 insertions(+), 1 deletion(-)
|
14
|
-
|
15
|
-
diff --git a/parser.c b/parser.c
|
16
|
-
index 1e714e7..0b8d633 100644
|
17
|
-
--- a/parser.c
|
18
|
-
+++ b/parser.c
|
19
|
-
@@ -6904,7 +6904,9 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
|
20
|
-
"All markup of the conditional section is not in the same entity\n",
|
21
|
-
NULL, NULL);
|
22
|
-
}
|
23
|
-
- SKIP(3);
|
24
|
-
+ if ((ctxt-> instate != XML_PARSER_EOF) &&
|
25
|
-
+ ((ctxt->input->cur + 3) < ctxt->input->end))
|
26
|
-
+ SKIP(3);
|
27
|
-
}
|
28
|
-
}
|
29
|
-
|
30
|
-
--
|
31
|
-
2.5.0
|
32
|
-
|