diff --git a/examples/server.cc b/examples/server.cc index 4020e95cdcac7b9c05a75d9ce013e86aaf1912e4..0d5d0d7691ad1037dc61011d9b34797491555c9d 100644 --- a/examples/server.cc +++ b/examples/server.cc @@ -2390,7 +2390,8 @@ int Server::on_read(Endpoint &ep) { continue; } - if (hd.token.base[0] != RETRY_TOKEN_MAGIC && hd.dcid.datalen < 8) { + if (hd.token.base[0] != RETRY_TOKEN_MAGIC && + hd.dcid.datalen < NGTCP2_MIN_INITIAL_DCIDLEN) { send_stateless_connection_close(&hd, ep, &su.sa, addrlen); continue; } diff --git a/lib/includes/ngtcp2/ngtcp2.h b/lib/includes/ngtcp2/ngtcp2.h index 04b568c1bb835f172ed9b9d7bedfd117b1fa9d49..c8ec97239cbb635ddd1e879c43715af7c3e1c214 100644 --- a/lib/includes/ngtcp2/ngtcp2.h +++ b/lib/includes/ngtcp2/ngtcp2.h @@ -320,6 +320,11 @@ typedef uint64_t ngtcp2_duration; /* NGTCP2_MIN_CIDLEN is the minimum length of Connection ID. */ #define NGTCP2_MIN_CIDLEN 1 +/* NGTCP2_MIN_INITIAL_DCIDLEN is the minimum length of Destination + Connection ID in Client Initial packet if it does not bear token + from Retry packet. */ +#define NGTCP2_MIN_INITIAL_DCIDLEN 8 + /** * @struct * diff --git a/lib/ngtcp2_conn.c b/lib/ngtcp2_conn.c index c0831da34a9b2d3a0cf09fb4e78adcb3b77608fc..caf94dfcbeb5bf680cbe8f62aee4f83ac626ad1b 100644 --- a/lib/ngtcp2_conn.c +++ b/lib/ngtcp2_conn.c @@ -7845,7 +7845,7 @@ int ngtcp2_accept(ngtcp2_pkt_hd *dest, const uint8_t *pkt, size_t pktlen) { if (pktlen < NGTCP2_MIN_INITIAL_PKTLEN) { return -1; } - if (p->token.len == 0 && p->dcid.datalen < 8) { + if (p->token.len == 0 && p->dcid.datalen < NGTCP2_MIN_INITIAL_DCIDLEN) { return -1; } break;