quic: fix non-null terminated hostname string 63/21963/2
authorBenoît Ganne <bganne@cisco.com>
Tue, 10 Sep 2019 16:42:09 +0000 (18:42 +0200)
committerDamjan Marion <dmarion@me.com>
Wed, 11 Sep 2019 19:31:44 +0000 (19:31 +0000)
Type: fix

Change-Id: I089d359d5726050f32f69366547086216fdb3098
Signed-off-by: Benoît Ganne <bganne@cisco.com>
src/plugins/quic/quic.c

index 42a839d..4a465fc 100644 (file)
@@ -1085,16 +1085,12 @@ quic_connect_new_connection (session_endpoint_cfg_t * sep)
   ctx->client_opaque = sep->opaque;
   ctx->c_flags |= TRANSPORT_CONNECTION_F_NO_LOOKUP;
   if (sep->hostname)
-    {
-      ctx->srv_hostname = format (0, "%v", sep->hostname);
-      vec_terminate_c_string (ctx->srv_hostname);
-    }
+    ctx->srv_hostname = format (0, "%v", sep->hostname);
   else
-    {
-      /*  needed by quic for crypto + determining client / server */
-      ctx->srv_hostname =
-       format (0, "%U", format_ip46_address, &sep->ip, sep->is_ip4);
-    }
+    /*  needed by quic for crypto + determining client / server */
+    ctx->srv_hostname =
+      format (0, "%U", format_ip46_address, &sep->ip, sep->is_ip4);
+  vec_terminate_c_string (ctx->srv_hostname);
 
   clib_memcpy (&cargs->sep, sep, sizeof (session_endpoint_cfg_t));
   cargs->sep.transport_proto = TRANSPORT_PROTO_UDPC;