Unverified Commit 5b529381 by Christian Brauner Committed by Stéphane Graber

confile: do not write out trailing spaces

So far do_append_unexp_config_line() wrote out a trailing space each time the config item value was empty. This is a problem a) when we later on parse the written out config file we need to remove trailing spaces and b). Signed-off-by: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
parent 08a46538
......@@ -2703,10 +2703,16 @@ void write_config(FILE *fout, struct lxc_conf *c)
bool do_append_unexp_config_line(struct lxc_conf *conf, const char *key, const char *v)
{
int ret;
size_t len = strlen(key) + strlen(v) + 4;
char *tmp = alloca(len);
size_t len;
char *tmp;
ret = snprintf(tmp, len, "%s = %s", key, v);
len = strlen(key) + strlen(v) + 4;
tmp = alloca(len);
if (config_value_empty(v))
ret = snprintf(tmp, len, "%s =", key);
else
ret = snprintf(tmp, len, "%s = %s", key, v);
if (ret < 0 || ret >= len)
return false;
......
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