From d6246c31a1238d065b4d9690d3bac740326f6485 Mon Sep 17 00:00:00 2001
From: Sebastian Pipping
+/* Added in Expat 2.7.2. */ +XML_Bool +XML_SetAllocTrackerMaximumAmplification(XML_Parser p, + float maximumAmplificationFactor); ++
+ Sets the maximum tolerated amplification factor
+ between direct input and bytes of dynamic memory allocated
+ (default: 100.0)
+ of parser p to maximumAmplificationFactor, and
+ returns XML_TRUE upon success and XML_FALSE upon error.
+
+ Note: + There are three types of allocations that intentionally bypass tracking and limiting: +
+XML_MemMalloc
+ and
+ XML_MemRealloc
+ —
+ healthy use of these two functions continues to be a responsibility
+ of the application using Expat
+ —,
+ XML_GetBuffer
+ and
+ XML_ParseBuffer
+ (and thus also by plain
+ XML_Parse), and
+ XML_FreeContentModel).
+ The amplification factor is calculated as ..
+amplification := allocated / direct+
+ .. while parsing, whereas
+ direct is the number of bytes read from the primary document in parsing and
+ allocated is the number of bytes of dynamic memory allocated in the parser hierarchy.
+
For a call to XML_SetAllocTrackerMaximumAmplification to succeed:
p must be a non-NULL root parser (without any parent parsers) andmaximumAmplificationFactor must be non-NaN and greater than or equal to 1.0.+ Note: + If you ever need to increase this value for non-attack payload, + please file a bug report. +
+ ++ Note: + Amplifications factors greater than 100 can been observed near the start of parsing + even with benign files in practice. + + So if you do reduce the maximum allowed amplification, + please make sure that the activation threshold is still big enough + to not end up with undesired false positives (i.e. benign files being rejected). +
++/* Added in Expat 2.7.2. */ +XML_Bool +XML_SetAllocTrackerActivationThreshold(XML_Parser p, + unsigned long long activationThresholdBytes); ++
+ Sets number of allocated bytes of dynamic memory
+ needed to activate protection against disproportionate use of RAM
+ (default: 64 MiB)
+ of parser p to activationThresholdBytes, and
+ returns XML_TRUE upon success and XML_FALSE upon error.
+
+ Note:
+ For types of allocations that intentionally bypass tracking and limiting, please see
+ XML_SetAllocTrackerMaximumAmplification
+ above.
+
For a call to XML_SetAllocTrackerActivationThreshold to succeed:
p must be a non-NULL root parser (without any parent parsers).+ Note: + If you ever need to increase this value for non-attack payload, + please file a bug report. +
+/* Added in Expat 2.6.0. */