mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-24 13:33:01 +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:
@@ -584,6 +584,9 @@ xmlParserGrow(xmlParserCtxtPtr ctxt) {
|
|||||||
/* Don't grow push parser buffer. */
|
/* Don't grow push parser buffer. */
|
||||||
if ((ctxt->progressive) && (ctxt->inputNr <= 1))
|
if ((ctxt->progressive) && (ctxt->inputNr <= 1))
|
||||||
return(0);
|
return(0);
|
||||||
|
/* Don't grow memory buffers. */
|
||||||
|
if ((buf->encoder == NULL) && (buf->readcallback == NULL))
|
||||||
|
return(0);
|
||||||
if (buf->error != 0)
|
if (buf->error != 0)
|
||||||
return(-1);
|
return(-1);
|
||||||
|
|
||||||
@@ -633,6 +636,10 @@ xmlParserInputGrow(xmlParserInputPtr in, int len) {
|
|||||||
if (in->cur == NULL) return(-1);
|
if (in->cur == NULL) return(-1);
|
||||||
if (in->buf->buffer == 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;
|
indx = in->cur - in->base;
|
||||||
if (xmlBufUse(in->buf->buffer) > (unsigned int) indx + INPUT_CHUNK) {
|
if (xmlBufUse(in->buf->buffer) > (unsigned int) indx + INPUT_CHUNK) {
|
||||||
return(0);
|
return(0);
|
||||||
@@ -666,6 +673,11 @@ xmlParserShrink(xmlParserCtxtPtr ctxt) {
|
|||||||
|
|
||||||
if (buf == NULL)
|
if (buf == NULL)
|
||||||
return;
|
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;
|
used = in->cur - in->base;
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user