expat/backport-CVE-2013-0340-lib-Allow-test-suite-to-access-raw-accounting-values.patch

64 lines
1.7 KiB
Diff

From 8af7d22ff029796484c78a16d4c6d44a47cb5729 Mon Sep 17 00:00:00 2001
From: Sebastian Pipping <sebastian@pipping.org>
Date: Mon, 19 Apr 2021 21:44:38 +0200
Subject: [PATCH] lib: Allow test suite to access raw accounting values
---
lib/internal.h | 7 +++++++
lib/xmlparse.c | 14 ++++++++++++++
2 files changed, 21 insertions(+)
diff --git a/lib/internal.h b/lib/internal.h
index 40c5033..ce6d27a 100644
--- a/lib/internal.h
+++ b/lib/internal.h
@@ -139,6 +139,8 @@
8388608 // 8 MiB, 2^23
/* NOTE END */
+#include "expat.h" // so we can use type XML_Parser below
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -146,6 +148,11 @@ extern "C" {
_INTERNAL_trim_to_complete_utf8_characters(const char *from,
const char **fromLimRef);
+#if defined(XML_DTD)
+unsigned long long testingAccountingGetCountBytesDirect(XML_Parser parser);
+unsigned long long testingAccountingGetCountBytesIndirect(XML_Parser parser);
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/lib/xmlparse.c b/lib/xmlparse.c
index 4628def..fce7447 100644
--- a/lib/xmlparse.c
+++ b/lib/xmlparse.c
@@ -7357,6 +7357,20 @@ accountingDiffTolerated(XML_Parser originParser, int tok, const char *before,
return tolerated;
}
+unsigned long long
+testingAccountingGetCountBytesDirect(XML_Parser parser) {
+ if (! parser)
+ return 0;
+ return parser->m_accounting.countBytesDirect;
+}
+
+unsigned long long
+testingAccountingGetCountBytesIndirect(XML_Parser parser) {
+ if (! parser)
+ return 0;
+ return parser->m_accounting.countBytesIndirect;
+}
+
static void
entityTrackingReportStats(XML_Parser rootParser, ENTITY *entity,
const char *action, int sourceLine) {
--
1.8.3.1