mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-03-24 06:50:08 +03:00
parser: Don't grow or shrink pull parser memory buffers
Readd check for memory buffers without a read callback to avoid XML_MAX_LOOKUP_LIMIT errors if users provide a custom input buffer. Regressed with commit 834b8123 and later changes.
This commit is contained in:
parent
0e201722e4
commit
79a9938d84
@ -584,6 +584,9 @@ xmlParserGrow(xmlParserCtxtPtr ctxt) {
|
||||
/* Don't grow push parser buffer. */
|
||||
if ((ctxt->progressive) && (ctxt->inputNr <= 1))
|
||||
return(0);
|
||||
/* Don't grow memory buffers. */
|
||||
if ((buf->encoder == NULL) && (buf->readcallback == NULL))
|
||||
return(0);
|
||||
if (buf->error != 0)
|
||||
return(-1);
|
||||
|
||||
@ -633,6 +636,10 @@ xmlParserInputGrow(xmlParserInputPtr in, int len) {
|
||||
if (in->cur == NULL) return(-1);
|
||||
if (in->buf->buffer == NULL) return(-1);
|
||||
|
||||
/* Don't grow memory buffers. */
|
||||
if ((in->buf->encoder == NULL) && (in->buf->readcallback == NULL))
|
||||
return(0);
|
||||
|
||||
indx = in->cur - in->base;
|
||||
if (xmlBufUse(in->buf->buffer) > (unsigned int) indx + INPUT_CHUNK) {
|
||||
return(0);
|
||||
@ -666,6 +673,11 @@ xmlParserShrink(xmlParserCtxtPtr ctxt) {
|
||||
|
||||
if (buf == NULL)
|
||||
return;
|
||||
/* Don't shrink pull parser memory buffers. */
|
||||
if (((ctxt->progressive == 0) || (ctxt->inputNr > 1)) &&
|
||||
(buf->encoder == NULL) &&
|
||||
(buf->readcallback == NULL))
|
||||
return;
|
||||
|
||||
used = in->cur - in->base;
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user