]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
tls: don't accept NULL ALPN name in TLS_CreateInstance()
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 6 Aug 2025 14:21:57 +0000 (16:21 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 7 Aug 2025 08:18:31 +0000 (10:18 +0200)
The TLS_CreateInstance() function handles a NULL alpn_name, but the
other session functions would crash if it was NULL. Change the function
to not handle the NULL for consistency and avoid potential confusion.

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

index 21ec7a4cda95bca5797b858a0be64deaf56c6bb3..eda1c2af0226b295cd2a9330297ecb1e1344070f 100644 (file)
@@ -174,7 +174,7 @@ TLS_CreateInstance(int server_mode, int sock_fd, const char *server_name, const
   inst->session = NULL;
   inst->server = server_mode;
   inst->label = Strdup(label);
-  inst->alpn_name = alpn_name ? Strdup(alpn_name) : NULL;
+  inst->alpn_name = Strdup(alpn_name);
 
   r = gnutls_init(&inst->session, GNUTLS_NONBLOCK | GNUTLS_NO_TICKETS |
                                   (server_mode ? GNUTLS_SERVER : GNUTLS_CLIENT));
@@ -238,9 +238,7 @@ TLS_DestroyInstance(TLS_Instance inst)
     gnutls_deinit(inst->session);
 
   Free(inst->label);
-
-  if (inst->alpn_name)
-    Free(inst->alpn_name);
+  Free(inst->alpn_name);
 
   Free(inst);
 }