From: Victor Julien Date: Thu, 19 Oct 2017 06:59:36 +0000 (+0200) Subject: yaml: print errors if integers are invalid X-Git-Tag: suricata-4.0.2~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=72dd663e00dfcea37d1c2d5dbc3ee99a2cd8e7d1;p=thirdparty%2Fsuricata.git yaml: print errors if integers are invalid --- diff --git a/src/conf.c b/src/conf.c index cf05a4940f..bde495da8f 100644 --- a/src/conf.c +++ b/src/conf.c @@ -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;