conf/ile: avoid atoi in config_lsm_aa_incomplete()

parent 91863d36
...@@ -317,7 +317,7 @@ struct lxc_conf { ...@@ -317,7 +317,7 @@ struct lxc_conf {
struct lxc_list hooks[NUM_LXC_HOOKS]; struct lxc_list hooks[NUM_LXC_HOOKS];
char *lsm_aa_profile; char *lsm_aa_profile;
int lsm_aa_allow_incomplete; unsigned int lsm_aa_allow_incomplete;
char *lsm_se_context; char *lsm_se_context;
int tmp_umount_proc; int tmp_umount_proc;
char *seccomp; // filename with the seccomp rules char *seccomp; // filename with the seccomp rules
......
...@@ -1293,9 +1293,13 @@ static int config_lsm_aa_profile(const char *key, const char *value, ...@@ -1293,9 +1293,13 @@ static int config_lsm_aa_profile(const char *key, const char *value,
static int config_lsm_aa_incomplete(const char *key, const char *value, static int config_lsm_aa_incomplete(const char *key, const char *value,
struct lxc_conf *lxc_conf) struct lxc_conf *lxc_conf)
{ {
int v = atoi(value); if (lxc_safe_uint(value, &lxc_conf->lsm_aa_allow_incomplete) < 0)
return -1;
lxc_conf->lsm_aa_allow_incomplete = v == 1 ? 1 : 0; if (lxc_conf->lsm_aa_allow_incomplete > 1) {
ERROR("Wrong value for lxc.lsm_aa_allow_incomplete. Can only be set to 0 or 1");
return -1;
}
return 0; return 0;
} }
...@@ -1327,10 +1331,12 @@ static int config_loglevel(const char *key, const char *value, ...@@ -1327,10 +1331,12 @@ static int config_loglevel(const char *key, const char *value,
if (!value || strlen(value) == 0) if (!value || strlen(value) == 0)
return 0; return 0;
if (value[0] >= '0' && value[0] <= '9') if (value[0] >= '0' && value[0] <= '9') {
newlevel = atoi(value); if (lxc_safe_int(value, &newlevel) < 0)
else return -1;
} else {
newlevel = lxc_log_priority_to_int(value); newlevel = lxc_log_priority_to_int(value);
}
// store these values in the lxc_conf, and then try to set for // store these values in the lxc_conf, and then try to set for
// actual current logging. // actual current logging.
lxc_conf->loglevel = newlevel; lxc_conf->loglevel = newlevel;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment