Skip to content

Commit 8ccfc6a

Browse files
committed
Fix request body partial processing for XML
Pass 0 (false) as the terminate argument of the last call of xmlParseChunk when partial processing is enabled and the length exceeds the limit.
1 parent a7d1198 commit 8ccfc6a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

apache2/msc_xml.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,10 +304,12 @@ int xml_complete(modsec_rec *msr, char **error_msg) {
304304

305305
/* Only if we have a context, meaning we've done some work. */
306306
if (msr->xml->parsing_ctx != NULL || msr->xml->parsing_ctx_arg != NULL) {
307+
int terminate = !msr->reqbody_partial_processing_enabled;
308+
307309
if (msr->xml->parsing_ctx != NULL &&
308310
msr->txcfg->parse_xml_into_args != MSC_XML_ARGS_ONLYARGS) {
309311
/* This is how we signal the end of parsing to libxml. */
310-
xmlParseChunk(msr->xml->parsing_ctx, NULL, 0, 1);
312+
xmlParseChunk(msr->xml->parsing_ctx, NULL, 0, terminate);
311313

312314
/* Preserve the results for our reference. */
313315
msr->xml->well_formed = msr->xml->parsing_ctx->wellFormed;
@@ -326,7 +328,7 @@ int xml_complete(modsec_rec *msr, char **error_msg) {
326328

327329
if (msr->xml->parsing_ctx_arg != NULL &&
328330
msr->txcfg->parse_xml_into_args != MSC_XML_ARGS_OFF) {
329-
if (xmlParseChunk(msr->xml->parsing_ctx_arg, NULL, 0, 1) != 0) {
331+
if (xmlParseChunk(msr->xml->parsing_ctx_arg, NULL, 0, terminate) != 0) {
330332
if (msr->xml->xml_error) {
331333
*error_msg = msr->xml->xml_error;
332334
}

0 commit comments

Comments
 (0)