From ff6cb4ed82e72bd301a50cc4fc783c13ee2bc5e8 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Fri, 28 Oct 2016 20:22:35 +0200 Subject: [PATCH] conf/ile: use lxc_safe_uint() in config_autodev() Signed-off-by: Christian Brauner --- src/lxc/conf.h | 2 +- src/lxc/confile.c | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/lxc/conf.h b/src/lxc/conf.h index 6532d8e27..283042c78 100644 --- a/src/lxc/conf.h +++ b/src/lxc/conf.h @@ -325,7 +325,7 @@ struct lxc_conf { scmp_filter_ctx seccomp_ctx; #endif int maincmd_fd; - int autodev; // if 1, mount and fill a /dev at start + unsigned int autodev; // if 1, mount and fill a /dev at start int haltsignal; // signal used to halt container int rebootsignal; // signal used to reboot container int stopsignal; // signal used to hard stop container diff --git a/src/lxc/confile.c b/src/lxc/confile.c index 331a36dd9..dad7a73f3 100644 --- a/src/lxc/confile.c +++ b/src/lxc/confile.c @@ -1346,9 +1346,13 @@ static int config_loglevel(const char *key, const char *value, static int config_autodev(const char *key, const char *value, struct lxc_conf *lxc_conf) { - int v = atoi(value); + if (lxc_safe_uint(value, &lxc_conf->autodev) < 0) + return -1; - lxc_conf->autodev = v; + if (lxc_conf->autodev > 1) { + ERROR("Wrong value for lxc.autodev. Can only be set to 0 or 1"); + return -1; + } return 0; }