confd: fix double free of container hostname

Fix a double free in the memory minefield surrounding container
hostname provisioning. The hostnamefmt() function already does free()
on success.

This caused all sorts of mayhem when working with multiple containers.
However it mainly manifested itself by some containers not starting
due to there activation script being polluted with gibberish
name data. Your symptom might be different..

Example of polluted activation script:
container --hostname foobar --net veth0k -r always \
  create ^S@`M-}^G docker://ghcr.io/kernelkit/curios:edge

Signed-off-by: Richard Alpe <richard@bit42.se>
This commit is contained in:
Richard Alpe
2024-10-15 20:06:45 +02:00
parent e2e947629c
commit 3b4d2b38d7
+2 -4
View File
@@ -52,12 +52,10 @@ static int add(const char *name, struct lyd_node *cif)
if ((string = lydx_get_cattr(cif, "hostname"))) {
char *fmt = (char *)string;
if (hostnamefmt(&confd, &fmt)) {
if (hostnamefmt(&confd, &fmt))
ERRNO("%s: failed setting custom hostname", name);
} else {
else
fprintf(fp, " --hostname %s", fmt);
free(fmt);
}
}
if (lydx_is_enabled(cif, "read-only"))