]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
tls: don't call gnutls_deinit() after failed gnutls_init()
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 6 Aug 2025 13:07:18 +0000 (15:07 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 7 Aug 2025 08:18:31 +0000 (10:18 +0200)
Don't assume gnutls_init() leaves the session pointer at NULL when it
returns with an error status. It might be a session that was already
allocated and then freed without resetting it to NULL after an error.

Fixes: 3e32e7e69412 ("tls: move gnutls code into tls_gnutls.c")
tls_gnutls.c

index 2def9ee0c79e1a282c7587d028a34474df9ab46a..bb03cd68f5ba310ce00ea94d26dd9a844080a9e2 100644 (file)
@@ -180,6 +180,7 @@ TLS_CreateInstance(int server_mode, int sock_fd, const char *server_name,
                                   (server_mode ? GNUTLS_SERVER : GNUTLS_CLIENT));
   if (r < 0) {
     LOG(LOGS_ERR, "Could not %s TLS session : %s", "create", gnutls_strerror(r));
+    inst->session = NULL;
     goto error;
   }