From 3b4d2b38d70c372d8843b99aa808a615bb74fca3 Mon Sep 17 00:00:00 2001 From: Richard Alpe Date: Tue, 15 Oct 2024 20:06:45 +0200 Subject: [PATCH] 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 --- src/confd/src/infix-containers.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/confd/src/infix-containers.c b/src/confd/src/infix-containers.c index ef576c8f..27be820f 100644 --- a/src/confd/src/infix-containers.c +++ b/src/confd/src/infix-containers.c @@ -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"))