confile: cleanup set_config_uts_name()

parent f9d29e1f
...@@ -2618,7 +2618,7 @@ static int set_config_rootfs_options(const char *key, const char *value, ...@@ -2618,7 +2618,7 @@ static int set_config_rootfs_options(const char *key, const char *value,
static int set_config_uts_name(const char *key, const char *value, static int set_config_uts_name(const char *key, const char *value,
struct lxc_conf *lxc_conf, void *data) struct lxc_conf *lxc_conf, void *data)
{ {
struct utsname *utsname; __do_free struct utsname *utsname = NULL;
if (lxc_config_value_empty(value)) { if (lxc_config_value_empty(value)) {
clr_config_uts_name(key, lxc_conf, NULL); clr_config_uts_name(key, lxc_conf, NULL);
...@@ -2627,16 +2627,14 @@ static int set_config_uts_name(const char *key, const char *value, ...@@ -2627,16 +2627,14 @@ static int set_config_uts_name(const char *key, const char *value,
utsname = malloc(sizeof(*utsname)); utsname = malloc(sizeof(*utsname));
if (!utsname) if (!utsname)
return -1; return ret_errno(ENOMEM);
if (strlen(value) >= sizeof(utsname->nodename)) { if (strlen(value) >= sizeof(utsname->nodename))
free(utsname); return ret_errno(EINVAL);
return -1;
}
(void)strlcpy(utsname->nodename, value, sizeof(utsname->nodename)); (void)strlcpy(utsname->nodename, value, sizeof(utsname->nodename));
free(lxc_conf->utsname); free(lxc_conf->utsname);
lxc_conf->utsname = utsname; lxc_conf->utsname = move_ptr(utsname);
return 0; return 0;
} }
......
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