Source code

Revision control

Copy as Markdown

Other Tools

diff --git a/expat/lib/xmlparse.c b/expat/lib/xmlparse.c
--- a/expat/lib/xmlparse.c
+++ b/expat/lib/xmlparse.c
@@ -456,24 +456,36 @@ typedef unsigned long long XmlBigCount;
typedef struct accounting {
XmlBigCount countBytesDirect;
XmlBigCount countBytesIndirect;
+/* BEGIN MOZILLA CHANGE (don't report debug information) */
+#if 0
unsigned long debugLevel;
+#endif
+/* END MOZILLA CHANGE */
float maximumAmplificationFactor; // >=1.0
unsigned long long activationThresholdBytes;
} ACCOUNTING;
typedef struct MALLOC_TRACKER {
XmlBigCount bytesAllocated;
+/* BEGIN MOZILLA CHANGE (don't report debug information) */
+# if 0
XmlBigCount peakBytesAllocated; // updated live only for debug level >=2
unsigned long debugLevel;
+#endif
+/* END MOZILLA CHANGE */
float maximumAmplificationFactor; // >=1.0
XmlBigCount activationThresholdBytes;
} MALLOC_TRACKER;
typedef struct entity_stats {
+/* BEGIN MOZILLA CHANGE (don't report debug information) */
+#if 0
unsigned int countEverOpened;
unsigned int currentDepth;
unsigned int maximumDepthSeen;
unsigned long debugLevel;
+#endif
+/* END MOZILLA CHANGE */
} ENTITY_STATS;
#endif /* XML_GE == 1 */
@@ -632,18 +644,26 @@ static void parserInit(XML_Parser parser, const XML_Char *encodingName);
static float accountingGetCurrentAmplification(XML_Parser rootParser);
static void accountingReportStats(XML_Parser originParser, const char *epilog);
static void accountingOnAbort(XML_Parser originParser);
+/* BEGIN MOZILLA CHANGE (don't report debug information) */
+#if 0
static void accountingReportDiff(XML_Parser rootParser,
unsigned int levelsAwayFromRootParser,
const char *before, const char *after,
ptrdiff_t bytesMore, int source_line,
enum XML_Account account);
+#endif
+/* END MOZILLA CHANGE */
static XML_Bool accountingDiffTolerated(XML_Parser originParser, int tok,
const char *before, const char *after,
int source_line,
enum XML_Account account);
+/* BEGIN MOZILLA CHANGE (don't report debug information) */
+#if 0
static void entityTrackingReportStats(XML_Parser parser, ENTITY *entity,
const char *action, int sourceLine);
+#endif
+/* END MOZILLA CHANGE */
static void entityTrackingOnOpen(XML_Parser parser, ENTITY *entity,
int sourceLine);
static void entityTrackingOnClose(XML_Parser parser, ENTITY *entity,
@@ -653,8 +673,12 @@ static void entityTrackingOnClose(XML_Parser parser, ENTITY *entity,
static XML_Parser getRootParserOf(XML_Parser parser,
unsigned int *outLevelDiff);
+/* BEGIN MOZILLA CHANGE (don't report debug information) */
+#if 0
static unsigned long getDebugLevel(const char *variableName,
unsigned long defaultDebugLevel);
+#endif
+/* END MOZILLA CHANGE */
#define poolStart(pool) ((pool)->start)
#define poolLength(pool) ((pool)->ptr - (pool)->start)
@@ -814,6 +838,8 @@ struct XML_ParserStruct {
#endif
#if XML_GE == 1
+/* BEGIN MOZILLA CHANGE (don't report debug information) */
+#if 0
static void
expat_heap_stat(XML_Parser rootParser, char operator, XmlBigCount absDiff,
XmlBigCount newTotal, XmlBigCount peakTotal, int sourceLine) {
@@ -827,6 +853,8 @@ expat_heap_stat(XML_Parser rootParser, char operator, XmlBigCount absDiff,
(void *)rootParser, rootParser->m_accounting.countBytesDirect, operator,
absDiff, newTotal, peakTotal, (double)amplification, sourceLine);
}
+#endif
+/* END MOZILLA CHANGE */
static bool
expat_heap_increase_tolerable(XML_Parser rootParser, XmlBigCount increase,
@@ -855,9 +883,13 @@ expat_heap_increase_tolerable(XML_Parser rootParser, XmlBigCount increase,
}
}
+/* BEGIN MOZILLA CHANGE (don't report debug information) */
+#if 0
if (! tolerable && (rootParser->m_alloc_tracker.debugLevel >= 1)) {
expat_heap_stat(rootParser, '+', increase, newTotal, newTotal, sourceLine);
}
+#endif
+/* END MOZILLA CHANGE */
return tolerable;
}
@@ -901,6 +933,8 @@ expat_malloc(XML_Parser parser, size_t size, int sourceLine) {
// Update accounting
rootParser->m_alloc_tracker.bytesAllocated += bytesToAllocate;
+/* BEGIN MOZILLA CHANGE (don't report debug information) */
+#if 0
// Report as needed
if (rootParser->m_alloc_tracker.debugLevel >= 2) {
if (rootParser->m_alloc_tracker.bytesAllocated
@@ -912,6 +946,8 @@ expat_malloc(XML_Parser parser, size_t size, int sourceLine) {
rootParser->m_alloc_tracker.bytesAllocated,
rootParser->m_alloc_tracker.peakBytesAllocated, sourceLine);
}
+#endif
+/* END MOZILLA CHANGE */
return (char *)mallocedPtr + sizeof(size_t) + EXPAT_MALLOC_PADDING;
}
@@ -941,12 +977,16 @@ expat_free(XML_Parser parser, void *ptr, int sourceLine) {
assert(rootParser->m_alloc_tracker.bytesAllocated >= bytesAllocated);
rootParser->m_alloc_tracker.bytesAllocated -= bytesAllocated;
+/* BEGIN MOZILLA CHANGE (don't report debug information) */
+#if 0
// Report as needed
if (rootParser->m_alloc_tracker.debugLevel >= 2) {
expat_heap_stat(rootParser, '-', bytesAllocated,
rootParser->m_alloc_tracker.bytesAllocated,
rootParser->m_alloc_tracker.peakBytesAllocated, sourceLine);
}
+#endif
+/* END MOZILLA CHANGE */
// NOTE: This may be freeing rootParser, so freeing has to come last
parser->m_mem.free_fcn(mallocedPtr);
@@ -1011,6 +1051,8 @@ expat_realloc(XML_Parser parser, void *ptr, size_t size, int sourceLine) {
rootParser->m_alloc_tracker.bytesAllocated -= absDiff;
}
+/* BEGIN MOZILLA CHANGE (don't report debug information) */
+#if 0
// Report as needed
if (rootParser->m_alloc_tracker.debugLevel >= 2) {
if (rootParser->m_alloc_tracker.bytesAllocated
@@ -1022,6 +1064,8 @@ expat_realloc(XML_Parser parser, void *ptr, size_t size, int sourceLine) {
rootParser->m_alloc_tracker.bytesAllocated,
rootParser->m_alloc_tracker.peakBytesAllocated, sourceLine);
}
+#endif
+/* END MOZILLA CHANGE */
// Update in-block recorded size
*(size_t *)mallocedPtr = size;
@@ -1431,8 +1475,12 @@ parserCreate(const XML_Char *encodingName,
// Initialize .m_alloc_tracker
memset(&parser->m_alloc_tracker, 0, sizeof(MALLOC_TRACKER));
if (parentParser == NULL) {
+/* BEGIN MOZILLA CHANGE (don't report debug information) */
+#if 0
parser->m_alloc_tracker.debugLevel
= getDebugLevel("EXPAT_MALLOC_DEBUG", 0u);
+#endif
+/* END MOZILLA CHANGE */
parser->m_alloc_tracker.maximumAmplificationFactor
= EXPAT_ALLOC_TRACKER_MAXIMUM_AMPLIFICATION_DEFAULT;
parser->m_alloc_tracker.activationThresholdBytes
@@ -1452,6 +1500,8 @@ parserCreate(const XML_Char *encodingName,
assert(SIZE_MAX - rootParser->m_alloc_tracker.bytesAllocated >= increase);
rootParser->m_alloc_tracker.bytesAllocated += increase;
+/* BEGIN MOZILLA CHANGE (don't report debug information) */
+#if 0
// Report on allocation
if (rootParser->m_alloc_tracker.debugLevel >= 2) {
if (rootParser->m_alloc_tracker.bytesAllocated
@@ -1464,6 +1514,8 @@ parserCreate(const XML_Char *encodingName,
rootParser->m_alloc_tracker.bytesAllocated,
rootParser->m_alloc_tracker.peakBytesAllocated, __LINE__);
}
+#endif
+/* END MOZILLA CHANGE */
#else
parser->m_parentParser = NULL;
#endif // XML_GE == 1
@@ -1644,15 +1696,23 @@ parserInit(XML_Parser parser, const XML_Char *encodingName) {
#if XML_GE == 1
memset(&parser->m_accounting, 0, sizeof(ACCOUNTING));
+/* BEGIN MOZILLA CHANGE (don't report debug information) */
+#if 0
parser->m_accounting.debugLevel = getDebugLevel("EXPAT_ACCOUNTING_DEBUG", 0u);
+#endif
+/* END MOZILLA CHANGE */
parser->m_accounting.maximumAmplificationFactor
= EXPAT_BILLION_LAUGHS_ATTACK_PROTECTION_MAXIMUM_AMPLIFICATION_DEFAULT;
parser->m_accounting.activationThresholdBytes
= EXPAT_BILLION_LAUGHS_ATTACK_PROTECTION_ACTIVATION_THRESHOLD_DEFAULT;
memset(&parser->m_entity_stats, 0, sizeof(ENTITY_STATS));
+/* BEGIN MOZILLA CHANGE (don't report debug information) */
+#if 0
parser->m_entity_stats.debugLevel = getDebugLevel("EXPAT_ENTITY_DEBUG", 0u);
#endif
+/* END MOZILLA CHANGE */
+#endif
}
/* moves list of bindings to m_freeBindingList */
@@ -8667,6 +8727,8 @@ accountingGetCurrentAmplification(XML_Parser rootParser) {
static void
accountingReportStats(XML_Parser originParser, const char *epilog) {
+/* BEGIN MOZILLA CHANGE (don't report debug information) */
+#if 0
const XML_Parser rootParser = getRootParserOf(originParser, NULL);
assert(! rootParser->m_parentParser);
@@ -8682,6 +8744,8 @@ accountingReportStats(XML_Parser originParser, const char *epilog) {
(void *)rootParser, rootParser->m_accounting.countBytesDirect,
rootParser->m_accounting.countBytesIndirect,
(double)amplificationFactor, epilog);
+#endif
+/* END MOZILLA CHANGE */
}
static void
@@ -8689,6 +8753,8 @@ accountingOnAbort(XML_Parser originParser) {
accountingReportStats(originParser, " ABORTING\n");
}
+/* BEGIN MOZILLA CHANGE (don't report debug information) */
+#if 0
static void
accountingReportDiff(XML_Parser rootParser,
unsigned int levelsAwayFromRootParser, const char *before,
@@ -8725,6 +8791,8 @@ accountingReportDiff(XML_Parser rootParser,
}
fprintf(stderr, "\"\n");
}
+#endif
+/* END MOZILLA CHANGE */
static XML_Bool
accountingDiffTolerated(XML_Parser originParser, int tok, const char *before,
@@ -8772,11 +8840,15 @@ accountingDiffTolerated(XML_Parser originParser, int tok, const char *before,
|| (amplificationFactor
<= rootParser->m_accounting.maximumAmplificationFactor);
+/* BEGIN MOZILLA CHANGE (don't report debug information) */
+#if 0
if (rootParser->m_accounting.debugLevel >= 2u) {
accountingReportStats(rootParser, "");
accountingReportDiff(rootParser, levelsAwayFromRootParser, before, after,
bytesMore, source_line, account);
}
+#endif
+/* END MOZILLA CHANGE */
return tolerated;
}
@@ -8795,6 +8867,8 @@ testingAccountingGetCountBytesIndirect(XML_Parser parser) {
return parser->m_accounting.countBytesIndirect;
}
+/* BEGIN MOZILLA CHANGE (don't report debug information) */
+#if 0
static void
entityTrackingReportStats(XML_Parser rootParser, ENTITY *entity,
const char *action, int sourceLine) {
@@ -8818,9 +8892,13 @@ entityTrackingReportStats(XML_Parser rootParser, ENTITY *entity,
entity->is_param ? "%" : "&", entityName, action, entity->textLen,
sourceLine);
}
+#endif
+/* END MOZILLA CHANGE */
static void
entityTrackingOnOpen(XML_Parser originParser, ENTITY *entity, int sourceLine) {
+/* BEGIN MOZILLA CHANGE (don't report debug information) */
+#if 0
const XML_Parser rootParser = getRootParserOf(originParser, NULL);
assert(! rootParser->m_parentParser);
@@ -8832,15 +8910,21 @@ entityTrackingOnOpen(XML_Parser originParser, ENTITY *entity, int sourceLine) {
}
entityTrackingReportStats(rootParser, entity, "OPEN ", sourceLine);
+#endif
+/* END MOZILLA CHANGE */
}
static void
entityTrackingOnClose(XML_Parser originParser, ENTITY *entity, int sourceLine) {
+/* BEGIN MOZILLA CHANGE (don't report debug information) */
+#if 0
const XML_Parser rootParser = getRootParserOf(originParser, NULL);
assert(! rootParser->m_parentParser);
entityTrackingReportStats(rootParser, entity, "CLOSE", sourceLine);
rootParser->m_entity_stats.currentDepth--;
+#endif
+/* END MOZILLA CHANGE */
}
#endif /* XML_GE == 1 */
@@ -8862,6 +8946,8 @@ getRootParserOf(XML_Parser parser, unsigned int *outLevelDiff) {
#if XML_GE == 1
+/* BEGIN MOZILLA CHANGE (don't report debug information) */
+#if 0
const char *
unsignedCharToPrintable(unsigned char c) {
switch (c) {
@@ -9385,9 +9471,13 @@ unsignedCharToPrintable(unsigned char c) {
assert(0); /* never gets here */
// LCOV_EXCL_STOP
}
+#endif
+/* END MOZILLA CHANGE */
#endif /* XML_GE == 1 */
+/* BEGIN MOZILLA CHANGE (don't report debug information) */
+#if 0
static unsigned long
getDebugLevel(const char *variableName, unsigned long defaultDebugLevel) {
const char *const valueOrNull = getenv(variableName);
@@ -9406,3 +9496,5 @@ getDebugLevel(const char *variableName, unsigned long defaultDebugLevel) {
return debugLevel;
}
+#endif
+/* END MOZILLA CHANGE */