From: Christian Brauner Date: Fri, 28 Oct 2016 18:26:51 +0000 (+0200) Subject: conf/ile: avoid atoi() in config_no_new_privs() X-Git-Tag: lxc-2.1.0~257^2~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e8ec7c9efce14398ec9611de5c04fd26e21cd38f;p=thirdparty%2Flxc.git conf/ile: avoid atoi() in config_no_new_privs() Signed-off-by: Christian Brauner --- diff --git a/src/lxc/confile.c b/src/lxc/confile.c index eccdcb54c..756b1ec61 100644 --- a/src/lxc/confile.c +++ b/src/lxc/confile.c @@ -2992,12 +2992,16 @@ static int config_syslog(const char *key, const char *value, static int config_no_new_privs(const char *key, const char *value, struct lxc_conf *lxc_conf) { - int v = atoi(value); + unsigned int v; - if (v != 0 && v != 1) { + if (lxc_safe_uint(value, &v) < 0) + return -1; + + if (v > 1) { ERROR("Wrong value for lxc.no_new_privs. Can only be set to 0 or 1"); return -1; } + lxc_conf->no_new_privs = v ? true : false; return 0;