From 00dadce92232a35f51f642a162fe38860e4dd905 Mon Sep 17 00:00:00 2001
From: Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>
Date: Fri, 5 Jun 2020 23:33:04 +0900
Subject: [PATCH] Fix ubsan error

---
 lib/includes/ngtcp2/ngtcp2.h | 2 +-
 tests/ngtcp2_conn_test.c     | 9 ++++++---
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/lib/includes/ngtcp2/ngtcp2.h b/lib/includes/ngtcp2/ngtcp2.h
index 5e5c2703..fa077b4b 100644
--- a/lib/includes/ngtcp2/ngtcp2.h
+++ b/lib/includes/ngtcp2/ngtcp2.h
@@ -731,7 +731,7 @@ typedef struct ngtcp2_addr {
   /* addrlen is the length of addr. */
   size_t addrlen;
   /* addr points to the buffer which contains endpoint address.  It is
-     opaque to the ngtcp2 library. */
+     opaque to the ngtcp2 library.  It must not be NULL. */
   uint8_t *addr;
   /* user_data is an arbitrary data and opaque to the library. */
   void *user_data;
diff --git a/tests/ngtcp2_conn_test.c b/tests/ngtcp2_conn_test.c
index 33d59012..4f0d8547 100644
--- a/tests/ngtcp2_conn_test.c
+++ b/tests/ngtcp2_conn_test.c
@@ -117,7 +117,8 @@ static uint8_t null_key[16];
 static uint8_t null_iv[16];
 static uint8_t null_hp_key[16];
 static uint8_t null_data[4096];
-static ngtcp2_path null_path = {};
+static ngtcp2_path null_path = {{1, (uint8_t *)"0", NULL},
+                                {1, (uint8_t *)"0", NULL}};
 static ngtcp2_path new_path = {{1, (uint8_t *)"1", NULL},
                                {1, (uint8_t *)"2", NULL}};
 
@@ -4361,8 +4362,10 @@ void test_ngtcp2_conn_server_path_validation(void) {
   const uint8_t raw_cid[] = {0x0f, 0x00, 0x00, 0x00};
   ngtcp2_cid cid, *new_cid;
   const uint8_t token[NGTCP2_STATELESS_RESET_TOKENLEN] = {0xff};
-  ngtcp2_path new_path1 = {{}, {1, (uint8_t *)"2", NULL}};
-  ngtcp2_path new_path2 = {{}, {1, (uint8_t *)"3", NULL}};
+  ngtcp2_path new_path1 = {{1, (uint8_t *)"0", NULL},
+                           {1, (uint8_t *)"2", NULL}};
+  ngtcp2_path new_path2 = {{1, (uint8_t *)"0", NULL},
+                           {1, (uint8_t *)"3", NULL}};
   ngtcp2_ksl_it it;
 
   ngtcp2_cid_init(&cid, raw_cid, sizeof(raw_cid));
-- 
GitLab