@@ -44,6 +44,7 @@ static void msc_xml_on_start_elementns(
44
44
// this is necessary because if there is any text between the tags (new line, etc)
45
45
// it will be added to the current value
46
46
xml_parser_state -> currval = NULL ;
47
+ xml_parser_state -> currpathbufflen = 0 ;
47
48
48
49
// if there is an item before the current one we set that has a child
49
50
if (xml_parser_state -> depth > 1 ) {
@@ -73,7 +74,11 @@ static void msc_xml_on_end_elementns(
73
74
if (msr -> txcfg -> debuglog_level >= 4 ) {
74
75
msr_log (msr , 4 , "Skipping request argument, over limit (XML): name \"%s\", value \"%s\"" ,
75
76
log_escape_ex (msr -> mp , xml_parser_state -> currpath , strlen (xml_parser_state -> currpath )),
76
- log_escape_ex (msr -> mp , xml_parser_state -> currval , strlen (xml_parser_state -> currval )));
77
+ log_escape_ex (msr -> mp ,
78
+ (xml_parser_state -> currval == NULL ? apr_pstrndup (msr -> mp , "" , 1 ) : xml_parser_state -> currval ),
79
+ (xml_parser_state -> currvalbufflen == 0 ? 1 : xml_parser_state -> currvalbufflen )
80
+ )
81
+ );
77
82
}
78
83
msr -> msc_reqbody_error = 1 ;
79
84
msr -> xml -> xml_error = apr_psprintf (msr -> mp , "More than %ld ARGS (GET + XML)" , msr -> txcfg -> arguments_limit );
@@ -86,7 +91,7 @@ static void msc_xml_on_end_elementns(
86
91
arg -> name = xml_parser_state -> currpath ;
87
92
arg -> name_len = strlen (arg -> name );
88
93
arg -> value = (xml_parser_state -> currval == NULL ) ? apr_pstrndup (msr -> mp , "" , 1 ) : xml_parser_state -> currval ;
89
- arg -> value_len = (xml_parser_state -> currval == NULL ) ? 0 : strlen ( xml_parser_state -> currval ) ;
94
+ arg -> value_len = (xml_parser_state -> currvalbufflen == 0 ) ? 1 : xml_parser_state -> currvalbufflen ;
90
95
arg -> value_origin_len = arg -> value_len ;
91
96
arg -> origin = "XML" ;
92
97
@@ -123,6 +128,7 @@ static void msc_xml_on_characters(void *ctx, const xmlChar *ch, int len) {
123
128
((xml_parser_state -> currval != NULL ) ? xml_parser_state -> currval : "" ),
124
129
apr_pstrndup (msr -> mp , (const char * )ch , len ),
125
130
NULL );
131
+ xml_parser_state -> currvalbufflen += len ;
126
132
// check if the memory allocation was successful
127
133
if (xml_parser_state -> currval == NULL ) {
128
134
msr -> xml -> xml_error = apr_psprintf (msr -> mp , "Failed to allocate memory for XML value." );
@@ -175,6 +181,7 @@ int xml_init(modsec_rec *msr, char **error_msg) {
175
181
msr -> xml -> xml_parser_state -> pathlen = 4 ; // "xml\0"
176
182
msr -> xml -> xml_parser_state -> currpath = apr_pstrdup (msr -> mp , "xml" );
177
183
msr -> xml -> xml_parser_state -> currval = NULL ;
184
+ msr -> xml -> xml_parser_state -> currvalbufflen = 0 ;
178
185
msr -> xml -> xml_parser_state -> currpathbufflen = 4 ;
179
186
// initialize the stack with item of 10
180
187
// this will store the information about nodes
0 commit comments