Skip to content

Commit 31dae62

Browse files
author
Marc Stern
committed
Don't store empty string before macro and empty macro result
1 parent 608cd1d commit 31dae62

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

apache2/re_actions.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,18 +228,20 @@ int expand_macros(modsec_rec *msr, msc_string *var, msre_rule *rule, apr_pool_t
228228
msre_var *var_resolved = NULL;
229229

230230
/* Add the text part before the macro to the array. */
231+
if (p != text_start) {
231232
part = (msc_string *)apr_pcalloc(mptmp, sizeof(msc_string));
232233
if (part == NULL) return -1;
233234
part->value_len = p - text_start;
234235
part->value = apr_pstrmemdup(mptmp, text_start, part->value_len);
235236
*(msc_string **)apr_array_push(arr) = part;
237+
}
236238

237239
/* Resolve the macro and add that to the array. */
238240
var_resolved = msre_create_var_ex(mptmp, msr->modsecurity->msre, var_name, var_value,
239241
msr, &my_error_msg);
240242
if (var_resolved != NULL) {
241243
var_generated = generate_single_var(msr, var_resolved, NULL, rule, mptmp);
242-
if (var_generated != NULL) {
244+
if (var_generated != NULL && var_generated->value_len) {
243245
part = (msc_string *)apr_pcalloc(mptmp, sizeof(msc_string));
244246
if (part == NULL) return -1;
245247
part->value_len = var_generated->value_len;

0 commit comments

Comments
 (0)