summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/conffile.c17
-rw-r--r--src/ulogd.c10
2 files changed, 26 insertions, 1 deletions
diff --git a/src/conffile.c b/src/conffile.c
index cc5552c..955956a 100644
--- a/src/conffile.c
+++ b/src/conffile.c
@@ -17,6 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <limits.h>
#include <ulogd/ulogd.h>
#include <ulogd/common.h>
#include <ulogd/conffile.h>
@@ -227,7 +228,21 @@ int config_parse_file(const char *section, struct config_keyset *kset)
}
break;
case CONFIG_TYPE_INT:
- ce->u.value = strtoul(args, NULL, 0);
+ errno = 0;
+ char *endptr = NULL;
+ long parsed = strtol(args, &endptr, 0);
+ if (endptr == args || *endptr != '\0') {
+ config_errce = ce;
+ err = -ERRINTFORMAT;
+ goto cpf_error;
+ }
+ if (errno == ERANGE ||
+ parsed < INT_MIN || parsed > INT_MAX) {
+ config_errce = ce;
+ err = -ERRINTRANGE;
+ goto cpf_error;
+ }
+ ce->u.value = (int)parsed;
break;
case CONFIG_TYPE_CALLBACK:
(ce->u.parser)(args);
diff --git a/src/ulogd.c b/src/ulogd.c
index 7260aeb..c844767 100644
--- a/src/ulogd.c
+++ b/src/ulogd.c
@@ -293,6 +293,16 @@ int ulogd_parse_configfile(const char *section, struct config_keyset *ce)
else
ulogd_log(ULOGD_ERROR, "string value is too long\n");
break;
+ case -ERRINTFORMAT:
+ ulogd_log(ULOGD_ERROR,
+ "integer has invalid format for key \"%s\"\n",
+ config_errce->key);
+ break;
+ case -ERRINTRANGE:
+ ulogd_log(ULOGD_ERROR,
+ "integer is out of range for key \"%s\"\n",
+ config_errce->key);
+ break;
}
return ULOGD_IRET_ERR;