QUIC Wire Format Encoding: Fix handling of zero-length parameters
authorHugo Landau <hlandau@openssl.org>
Mon, 31 Oct 2022 15:48:18 +0000 (15:48 +0000)
committerHugo Landau <hlandau@openssl.org>
Fri, 13 Jan 2023 13:20:12 +0000 (13:20 +0000)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19703)

ssl/quic/quic_wire.c

index bc66f6c592f8c318a6002ea8ac9c3c98f0017de4..8bd1057d0d1bdce3384eb422dcecb8635b44c49c 100644 (file)
@@ -382,8 +382,12 @@ unsigned char *ossl_quic_wire_encode_transport_param_bytes(WPACKET *pkt,
     unsigned char *b = NULL;
 
     if (!WPACKET_quic_write_vlint(pkt, id)
-            || !WPACKET_quic_write_vlint(pkt, value_len)
-            || !WPACKET_allocate_bytes(pkt, value_len, (unsigned char **)&b))
+        || !WPACKET_quic_write_vlint(pkt, value_len))
+        return NULL;
+
+    if (value_len == 0)
+        b = WPACKET_get_curr(pkt);
+    else if (!WPACKET_allocate_bytes(pkt, value_len, (unsigned char **)&b))
         return NULL;
 
     if (value != NULL)