diff --git a/lib/includes/ngtcp2/ngtcp2.h b/lib/includes/ngtcp2/ngtcp2.h index 9567dde9195c4845bf8c478d1d040b8efd47cd90..04b568c1bb835f172ed9b9d7bedfd117b1fa9d49 100644 --- a/lib/includes/ngtcp2/ngtcp2.h +++ b/lib/includes/ngtcp2/ngtcp2.h @@ -385,8 +385,7 @@ typedef struct ngtcp2_pkt_stateless_reset { typedef struct ngtcp2_pkt_retry { ngtcp2_cid odcid; - const uint8_t *token; - size_t tokenlen; + ngtcp2_vec token; uint8_t tag[NGTCP2_RETRY_TAGLEN]; } ngtcp2_pkt_retry; diff --git a/lib/ngtcp2_conn.c b/lib/ngtcp2_conn.c index b70d030e338f6b30117ea37aafc886c078ad53fc..c0831da34a9b2d3a0cf09fb4e78adcb3b77608fc 100644 --- a/lib/ngtcp2_conn.c +++ b/lib/ngtcp2_conn.c @@ -3642,7 +3642,7 @@ static int conn_on_retry(ngtcp2_conn *conn, const ngtcp2_pkt_hd *hd, (const char *)ngtcp2_encode_hex(cidbuf, retry.odcid.data, retry.odcid.datalen)); - if (retry.tokenlen == 0) { + if (retry.token.len == 0) { return NGTCP2_ERR_PROTO; } @@ -3693,13 +3693,13 @@ static int conn_on_retry(ngtcp2_conn *conn, const ngtcp2_pkt_hd *hd, token->base = NULL; token->len = 0; - token->base = ngtcp2_mem_malloc(conn->mem, retry.tokenlen); + token->base = ngtcp2_mem_malloc(conn->mem, retry.token.len); if (token->base == NULL) { return NGTCP2_ERR_NOMEM; } - token->len = retry.tokenlen; + token->len = retry.token.len; - ngtcp2_cpymem(token->base, retry.token, retry.tokenlen); + ngtcp2_cpymem(token->base, retry.token.base, retry.token.len); conn_reset_congestion_state(conn); diff --git a/lib/ngtcp2_pkt.c b/lib/ngtcp2_pkt.c index 07c9e146e60d91b7d9d7c9323951d3ada86ae694..0e20aa45d4e5cab0afc38e51d55c5c8be9d0bd01 100644 --- a/lib/ngtcp2_pkt.c +++ b/lib/ngtcp2_pkt.c @@ -1988,9 +1988,9 @@ int ngtcp2_pkt_decode_retry(ngtcp2_pkt_retry *dest, const uint8_t *payload, return NGTCP2_ERR_INVALID_ARGUMENT; } - dest->token = payload; - dest->tokenlen = (size_t)(payloadlen - NGTCP2_RETRY_TAGLEN); - ngtcp2_cpymem(dest->tag, payload + dest->tokenlen, NGTCP2_RETRY_TAGLEN); + dest->token.base = (uint8_t *)payload; + dest->token.len = (size_t)(payloadlen - NGTCP2_RETRY_TAGLEN); + ngtcp2_cpymem(dest->tag, payload + dest->token.len, NGTCP2_RETRY_TAGLEN); return 0; } diff --git a/tests/ngtcp2_pkt_test.c b/tests/ngtcp2_pkt_test.c index 8946d09c40636d55c705793a78d0682d2cab6f57..670fb1875e95a9f09011e8b51b95475d79294e9c 100644 --- a/tests/ngtcp2_pkt_test.c +++ b/tests/ngtcp2_pkt_test.c @@ -1288,7 +1288,8 @@ void test_ngtcp2_pkt_write_retry(void) { rv = ngtcp2_pkt_decode_retry(&retry, buf + nread, (size_t)(spktlen - nread)); CU_ASSERT(0 == rv); - CU_ASSERT(0 == memcmp(token, retry.token, sizeof(token))); + CU_ASSERT(sizeof(token) == retry.token.len); + CU_ASSERT(0 == memcmp(token, retry.token.base, sizeof(token))); CU_ASSERT(0 == memcmp(tag, retry.tag, sizeof(tag))); }