summaryrefslogtreecommitdiff
blob: 61de4d624a8f65364e8f954bb8f121289ddc34ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
From 153cf15905cf4ec080612ada6703757d10caba1e Mon Sep 17 00:00:00 2001
From: Daniel Veillard <veillard@redhat.com>
Date: Fri, 26 Oct 2012 13:50:47 +0800
Subject: [PATCH] Fix large parse of file from memory

https://bugzilla.redhat.com/show_bug.cgi?id=862969
The new code trying to detect excessive input lookup would
just get wrong sometimes in the case of very large file parsed
directly from memory.
---
 libxml.h | 2 ++
 parser.c | 1 +
 xmlIO.c  | 2 +-
 3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/libxml.h b/libxml.h
index efe285b..7558b5f 100644
--- a/libxml.h
+++ b/libxml.h
@@ -91,6 +91,8 @@ void __xmlGlobalInitMutexDestroy(void);
 int __xmlRandom(void);
 #endif
 
+int xmlNop(void);
+
 #ifdef IN_LIBXML
 #ifdef __GNUC__
 #ifdef PIC
diff --git a/parser.c b/parser.c
index 43f53d9..0d8d7f2 100644
--- a/parser.c
+++ b/parser.c
@@ -2025,6 +2025,7 @@ static void xmlSHRINK (xmlParserCtxtPtr ctxt) {
 static void xmlGROW (xmlParserCtxtPtr ctxt) {
     if ((((ctxt->input->end - ctxt->input->cur) > XML_MAX_LOOKUP_LIMIT) ||
          ((ctxt->input->cur - ctxt->input->base) > XML_MAX_LOOKUP_LIMIT)) &&
+         ((ctxt->input->buf) && (ctxt->input->buf->readcallback != xmlNop)) &&
         ((ctxt->options & XML_PARSE_HUGE) == 0)) {
         xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR, "Huge input lookup");
         ctxt->instate = XML_PARSER_EOF;
diff --git a/xmlIO.c b/xmlIO.c
index f8f438b..44254e4 100644
--- a/xmlIO.c
+++ b/xmlIO.c
@@ -800,7 +800,7 @@ xmlCheckFilename (const char *path)
     return 1;
 }
 
-static int
+int
 xmlNop(void) {
     return(0);
 }
-- 
1.8.0