Skip to content

Commit

Permalink
conf/ile: avoid atoi() in config_ephemeral()
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 authored and stgraber committed Nov 22, 2016
1 parent 856a573 commit 16ba55a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/lxc/conf.h
Expand Up @@ -377,7 +377,7 @@ struct lxc_conf {
gid_t init_gid;

/* indicator if the container will be destroyed on shutdown */
int ephemeral;
unsigned int ephemeral;
};

#ifdef HAVE_TLS
Expand Down
7 changes: 3 additions & 4 deletions src/lxc/confile.c
Expand Up @@ -2955,13 +2955,12 @@ bool network_new_hwaddrs(struct lxc_conf *conf)
static int config_ephemeral(const char *key, const char *value,
struct lxc_conf *lxc_conf)
{
int v = atoi(value);
if (lxc_safe_uint(value, &lxc_conf->ephemeral) < 0)
return -1;

if (v != 0 && v != 1) {
if (lxc_conf->ephemeral > 1) {
ERROR("Wrong value for lxc.ephemeral. Can only be set to 0 or 1");
return -1;
} else {
lxc_conf->ephemeral = v;
}

return 0;
Expand Down

0 comments on commit 16ba55a

Please sign in to comment.