Just delete 0rtt buffered packets if 0rtt key is not available
@@ -4564,10 +4564,13 @@ static ssize_t conn_recv_pkt(ngtcp2_conn *conn, const uint8_t *pkt,
static int conn_process_buffered_protected_pkt(ngtcp2_conn *conn,
ngtcp2_tstamp ts) {
ssize_t nread;
- ngtcp2_pkt_chain *pc = conn->buffed_rx_ppkts, *next;
+ ngtcp2_pkt_chain *pc, *next;
- for (; pc; pc = pc->next) {
+ for (pc = conn->buffed_rx_ppkts; pc;) {
+ next = pc->next;
nread = conn_recv_pkt(conn, pc->pkt, pc->pktlen, ts);
+ ngtcp2_pkt_chain_del(pc, conn->mem);
+ pc = next;
if (nread < 0) {
if (nread == NGTCP2_ERR_DISCARD_PKT) {
continue;
@@ -4576,12 +4579,6 @@ static int conn_process_buffered_protected_pkt(ngtcp2_conn *conn,
}
}
- for (pc = conn->buffed_rx_ppkts; pc;) {
- next = pc->next;
- ngtcp2_pkt_chain_del(pc, conn->mem);
- pc = next;
- }
-
conn->buffed_rx_ppkts = NULL;
return 0;
@@ -4590,10 +4587,13 @@ static int conn_process_buffered_protected_pkt(ngtcp2_conn *conn,
static int conn_process_buffered_handshake_pkt(ngtcp2_conn *conn,
ngtcp2_tstamp ts) {
ssize_t nread;
- ngtcp2_pkt_chain *pc = conn->buffed_rx_hs_pkts, *next;
+ ngtcp2_pkt_chain *pc, *next;
- for (; pc; pc = pc->next) {
+ for (pc = conn->buffed_rx_hs_pkts; pc;) {
+ next = pc->next;
nread = conn_recv_handshake_pkt(conn, pc->pkt, pc->pktlen, ts);
+ ngtcp2_pkt_chain_del(pc, conn->mem);
+ pc = next;
if (nread < 0) {
if (nread == NGTCP2_ERR_DISCARD_PKT) {
continue;
@@ -4602,12 +4602,6 @@ static int conn_process_buffered_handshake_pkt(ngtcp2_conn *conn,
}
}
- for (pc = conn->buffed_rx_hs_pkts; pc;) {
- next = pc->next;
- ngtcp2_pkt_chain_del(pc, conn->mem);
- pc = next;
- }
-
conn->buffed_rx_hs_pkts = NULL;
return 0;
@@ -4792,10 +4786,15 @@ int ngtcp2_conn_read_handshake(ngtcp2_conn *conn, const uint8_t *pkt,
/* Process re-ordered 0-RTT Protected packets which were
arrived before Initial packet. */
+ if (conn->early_ckm) {
rv = conn_process_buffered_protected_pkt(conn, ts);
if (rv != 0) {
return rv;
}
+ } else {
+ delete_buffed_pkts(conn->buffed_rx_ppkts, conn->mem);
+ conn->buffed_rx_ppkts = NULL;
+ }
return 0;
case NGTCP2_CS_SERVER_WAIT_HANDSHAKE:
