]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect/dataset: fix space condition in rule lang
authorShivani Bhardwaj <shivanib134@gmail.com>
Fri, 28 Jan 2022 20:17:17 +0000 (01:47 +0530)
committerVictor Julien <vjulien@oisf.net>
Wed, 6 Apr 2022 06:22:24 +0000 (08:22 +0200)
If there is a space following a keyword that does not expect a value,
the rule fails to load due to improper value evaluation.
e.g. Space after "set" command
alert http any any -> any any (http.user_agent; dataset:set  ,ua-seen,type string,save datasets.csv; sid:1;)

gives error
[ERRCODE: SC_ERR_UNKNOWN_VALUE(129)] - dataset action "" is not supported.

Fix this by handling values correctly for such cases.

src/detect-dataset.c

index 393d11752a0a8a358c443f585ea6d8475dadd2e7..45efc062b2aed07e64320b1820116a5fc7ca3854 100644 (file)
@@ -129,13 +129,13 @@ static int DetectDatasetParse(const char *str, char *cmd, int cmd_len, char *nam
         }
 
         if (!cmd_set) {
-            if (val) {
+            if (val && strlen(val) != 0) {
                 return -1;
             }
             strlcpy(cmd, key, cmd_len);
             cmd_set = true;
         } else if (!name_set) {
-            if (val) {
+            if (val && strlen(val) != 0) {
                 return -1;
             }
             strlcpy(name, key, name_len);