Skip to content

Commit

Permalink
conf/ile: avoid atoi() in config_no_new_privs()
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Brauner <christian.brauner@canonical.com>
  • Loading branch information
Christian Brauner committed Nov 22, 2016
1 parent 66ffdb1 commit e8ec7c9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/lxc/confile.c
Expand Up @@ -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;
Expand Down

0 comments on commit e8ec7c9

Please sign in to comment.