diff --git a/expat/xmlwf/xmlwf.c b/expat/xmlwf/xmlwf.c index 2b1cf5ff..df271534 100644 --- a/expat/xmlwf/xmlwf.c +++ b/expat/xmlwf/xmlwf.c @@ -918,6 +918,9 @@ usage(const XML_Char *prog, int rc) { T(" -a FACTOR set maximum tolerated [a]mplification factor (default: 100.0)\n") T(" -b BYTES set number of output [b]ytes needed to activate (default: 8 MiB)\n") T("\n") + T("reparse deferral:\n") + T(" -q disable reparse deferral, and allow [q]uadratic parse runtime with large tokens\n") + T("\n") T("info arguments:\n") T(" -h, --help show this [h]elp message and exit\n") T(" -v, --version show program's [v]ersion number and exit\n") @@ -973,6 +976,8 @@ tmain(int argc, XML_Char **argv) { unsigned long long attackThresholdBytes = 0; XML_Bool attackThresholdGiven = XML_FALSE; + XML_Bool disableDeferral = XML_FALSE; + int exitCode = XMLWF_EXIT_SUCCESS; enum XML_ParamEntityParsing paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER; @@ -1125,6 +1130,11 @@ tmain(int argc, XML_Char **argv) { #endif break; } + case T('q'): { + disableDeferral = XML_TRUE; + j++; + break; + } case T('\0'): if (j > 1) { i++; @@ -1171,6 +1181,16 @@ tmain(int argc, XML_Char **argv) { #endif } + if (disableDeferral) { + const XML_Bool success = XML_SetReparseDeferralEnabled(parser, XML_FALSE); + if (! success) { + // This prevents tperror(..) from reporting misleading "[..]: Success" + errno = EINVAL; + tperror(T("Failed to disable reparse deferral")); + exit(XMLWF_EXIT_INTERNAL_ERROR); + } + } + if (requireStandalone) XML_SetNotStandaloneHandler(parser, notStandalone); XML_SetParamEntityParsing(parser, paramEntityParsing); diff --git a/expat/xmlwf/xmlwf_helpgen.py b/expat/xmlwf/xmlwf_helpgen.py index 7f89a4e9..a945f25c 100755 --- a/expat/xmlwf/xmlwf_helpgen.py +++ b/expat/xmlwf/xmlwf_helpgen.py @@ -82,6 +82,10 @@ billion_laughs.add_argument('-a', metavar='FACTOR', help='set maximum tolerated [a]mplification factor (default: 100.0)') billion_laughs.add_argument('-b', metavar='BYTES', help='set number of output [b]ytes needed to activate (default: 8 MiB)') +reparse_deferral = parser.add_argument_group('reparse deferral') +reparse_deferral.add_argument('-q', metavar='FACTOR', + help='disable reparse deferral, and allow [q]uadratic parse runtime with large tokens') + parser.add_argument('files', metavar='FILE', nargs='*', help='file to process (default: STDIN)') info = parser.add_argument_group('info arguments')