72 lines
2.1 KiB
Diff
72 lines
2.1 KiB
Diff
From 51c7019069b862e88d94ed228659e70bddd5de09 Mon Sep 17 00:00:00 2001
|
|
From: Sebastian Pipping <sebastian@pipping.org>
|
|
Date: Mon, 21 Oct 2024 01:42:54 +0200
|
|
Subject: [PATCH 1/3] lib: Make XML_StopParser refuse to stop/suspend an
|
|
unstarted parser
|
|
---
|
|
lib/expat.h | 4 +++-
|
|
lib/xmlparse.c | 11 ++++++++++-
|
|
2 files changed, 13 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/lib/expat.h b/lib/expat.h
|
|
index 29f0d1e..c5e7d02 100644
|
|
--- a/lib/expat.h
|
|
+++ b/lib/expat.h
|
|
@@ -117,7 +117,9 @@ enum XML_Error {
|
|
/* Added in 2.2.1. */
|
|
XML_ERROR_INVALID_ARGUMENT,
|
|
/* Added in 2.2.9. */
|
|
- XML_ERROR_AMPLIFICATION_LIMIT_BREACH
|
|
+ XML_ERROR_AMPLIFICATION_LIMIT_BREACH,
|
|
+ /* Added in 2.6.4. */
|
|
+ XML_ERROR_NOT_STARTED,
|
|
};
|
|
|
|
enum XML_Content_Type {
|
|
diff --git a/lib/xmlparse.c b/lib/xmlparse.c
|
|
index 56af19f..f06ed81 100644
|
|
--- a/lib/xmlparse.c
|
|
+++ b/lib/xmlparse.c
|
|
@@ -2173,6 +2173,9 @@ XML_StopParser(XML_Parser parser, XML_Bool resumable) {
|
|
if (parser == NULL)
|
|
return XML_STATUS_ERROR;
|
|
switch (parser->m_parsingStatus.parsing) {
|
|
+ case XML_INITIALIZED:
|
|
+ parser->m_errorCode = XML_ERROR_NOT_STARTED;
|
|
+ return XML_STATUS_ERROR;
|
|
case XML_SUSPENDED:
|
|
if (resumable) {
|
|
parser->m_errorCode = XML_ERROR_SUSPENDED;
|
|
@@ -2183,7 +2186,7 @@ XML_StopParser(XML_Parser parser, XML_Bool resumable) {
|
|
case XML_FINISHED:
|
|
parser->m_errorCode = XML_ERROR_FINISHED;
|
|
return XML_STATUS_ERROR;
|
|
- default:
|
|
+ case XML_PARSING:
|
|
if (resumable) {
|
|
#ifdef XML_DTD
|
|
if (parser->m_isParamEntity) {
|
|
@@ -2194,6 +2197,9 @@ XML_StopParser(XML_Parser parser, XML_Bool resumable) {
|
|
parser->m_parsingStatus.parsing = XML_SUSPENDED;
|
|
} else
|
|
parser->m_parsingStatus.parsing = XML_FINISHED;
|
|
+ break;
|
|
+ default:
|
|
+ assert(0);
|
|
}
|
|
return XML_STATUS_OK;
|
|
}
|
|
@@ -2454,6 +2460,9 @@ XML_ErrorString(enum XML_Error code) {
|
|
case XML_ERROR_AMPLIFICATION_LIMIT_BREACH:
|
|
return XML_L(
|
|
"limit on input amplification factor (from DTD and entities) breached");
|
|
+ /* Added in 2.6.4. */
|
|
+ case XML_ERROR_NOT_STARTED:
|
|
+ return XML_L("parser not started");
|
|
}
|
|
return NULL;
|
|
}
|
|
--
|
|
2.27.0
|
|
|