]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rule vars: strip leading white space before looking up var. 1599/head
authorJason Ish <ish@unx.ca>
Fri, 17 Jul 2015 22:22:59 +0000 (16:22 -0600)
committerJason Ish <ish@unx.ca>
Mon, 20 Jul 2015 04:56:04 +0000 (22:56 -0600)
src/util-rule-vars.c

index f060a14af1cbac77156433571d87f2894cf9d0b5..f3b5604fbed21af2eab2dfb5d7a0245e6855e48f 100644 (file)
@@ -74,6 +74,11 @@ char *SCRuleVarsGetConfVar(const DetectEngineCtx *de_ctx,
 
     if (conf_var_name == NULL)
         goto end;
+
+    while (conf_var_name[0] != '\0' && isspace(conf_var_name[0])) {
+        conf_var_name++;
+    }
+
     (conf_var_name[0] == '$') ? conf_var_name++ : conf_var_name;
     conf_var_type_name = SCMapEnumValueToName(conf_vars_type,
                                               sc_rule_vars_type_map);
@@ -214,6 +219,11 @@ int SCRuleVarsPositiveTest01(void)
                strcmp(SCRuleVarsGetConfVar(NULL,"$AIM_SERVERS", SC_RULE_VARS_ADDRESS_GROUPS),
                       "any") == 0);
 
+    /* Test that a leading space is stripped. */
+    result &= (SCRuleVarsGetConfVar(NULL," $AIM_SERVERS", SC_RULE_VARS_ADDRESS_GROUPS) != NULL &&
+               strcmp(SCRuleVarsGetConfVar(NULL," $AIM_SERVERS", SC_RULE_VARS_ADDRESS_GROUPS),
+                      "any") == 0);
+
     /* check for port-groups */
     result &= (SCRuleVarsGetConfVar(NULL,"$HTTP_PORTS", SC_RULE_VARS_PORT_GROUPS) != NULL &&
                strcmp(SCRuleVarsGetConfVar(NULL,"$HTTP_PORTS", SC_RULE_VARS_PORT_GROUPS),