]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
yaml: print errors if integers are invalid
authorVictor Julien <victor@inliniac.net>
Thu, 19 Oct 2017 06:59:36 +0000 (08:59 +0200)
committerVictor Julien <victor@inliniac.net>
Thu, 19 Oct 2017 08:40:06 +0000 (10:40 +0200)
src/conf.c

index cf05a4940f767bee565cbb4c91a3dbcc598c078e..bde495da8f14c6658290fe58c762ffcff20118a4 100644 (file)
@@ -388,10 +388,16 @@ int ConfGetInt(const char *name, intmax_t *val)
 
     errno = 0;
     tmpint = strtoimax(strval, &endptr, 0);
-    if (strval[0] == '\0' || *endptr != '\0')
+    if (strval[0] == '\0' || *endptr != '\0') {
+        SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY, "malformed integer value "
+                "for %s: '%s'", name, strval);
         return 0;
-    if (errno == ERANGE && (tmpint == INTMAX_MAX || tmpint == INTMAX_MIN))
+    }
+    if (errno == ERANGE && (tmpint == INTMAX_MAX || tmpint == INTMAX_MIN)) {
+        SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY, "integer value for %s out "
+                "of range: '%s'", name, strval);
         return 0;
+    }
 
     *val = tmpint;
     return 1;
@@ -407,10 +413,16 @@ int ConfGetChildValueInt(const ConfNode *base, const char *name, intmax_t *val)
         return 0;
     errno = 0;
     tmpint = strtoimax(strval, &endptr, 0);
-    if (strval[0] == '\0' || *endptr != '\0')
+    if (strval[0] == '\0' || *endptr != '\0') {
+        SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY, "malformed integer value "
+                "for %s with base %s: '%s'", name, base->name, strval);
         return 0;
-    if (errno == ERANGE && (tmpint == INTMAX_MAX || tmpint == INTMAX_MIN))
+    }
+    if (errno == ERANGE && (tmpint == INTMAX_MAX || tmpint == INTMAX_MIN)) {
+        SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY, "integer value for %s with "
+                " base %s out of range: '%s'", name, base->name, strval);
         return 0;
+    }
 
     *val = tmpint;
     return 1;