]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: ssl: ssl_sock_load_sctl_from_file memory leak
authorEmmanuel Hocdet <manu@gandi.net>
Thu, 16 Jan 2020 14:15:49 +0000 (15:15 +0100)
committerWilliam Lallemand <wlallemand@haproxy.org>
Tue, 21 Jan 2020 09:44:33 +0000 (10:44 +0100)
"set ssl cert <filename.sctl> <payload>" CLI command must free
previous context.

This patch should be backport to 2.1

src/ssl_sock.c

index e2c58a50fba6bf902b14183550d9e926d02aefa5..b898537eb918820866a8f120091472459ea29daa 100644 (file)
@@ -1606,10 +1606,14 @@ static int ssl_sock_load_sctl_from_file(const char *sctl_path, char *buf, struct
                sctl = NULL;
                goto end;
        }
-       ret = 0;
-       /* TODO: free the previous SCTL in the ckch */
+       /* no error, fill ckch with new context, old context must be free */
+       if (ckch->sctl) {
+               free(ckch->sctl->area);
+               ckch->sctl->area = NULL;
+               free(ckch->sctl);
+       }
        ckch->sctl = sctl;
-
+       ret = 0;
 end:
        if (fd != -1)
                close(fd);