@@ -5322,35 +5322,28 @@ int ngtcp2_conn_detect_lost_pkt(ngtcp2_conn *conn, ngtcp2_pktns *pktns,
5322
5322
* conn_recv_ack processes received ACK frame |fr|. |pkt_ts| is the
5323
5323
* timestamp when packet is received. |ts| should be the current
5324
5324
* time. Usually they are the same, but for buffered packets,
5325
- * |pkt_ts| would be earlier than |ts|.
5325
+ * |pkt_ts| would be earlier than |ts|. This function needs to be
5326
+ * called after |fr| is validated by ngtcp2_pkt_validate_ack.
5326
5327
*
5327
5328
* This function returns 0 if it succeeds, or one of the following
5328
5329
* negative error codes:
5329
5330
*
5330
5331
* NGTCP2_ERR_NOMEM
5331
5332
* Out of memory
5332
- * NGTCP2_ERR_ACK_FRAME
5333
- * ACK frame is malformed.
5334
5333
* NGTCP2_ERR_PROTO
5335
5334
* |fr| acknowledges a packet this endpoint has not sent.
5336
5335
* NGTCP2_ERR_CALLBACK_FAILURE
5337
5336
* User callback failed.
5338
5337
*/
5339
5338
static int conn_recv_ack (ngtcp2_conn * conn , ngtcp2_pktns * pktns , ngtcp2_ack * fr ,
5340
5339
ngtcp2_tstamp pkt_ts , ngtcp2_tstamp ts ) {
5341
- int rv ;
5342
5340
ngtcp2_ssize num_acked ;
5343
5341
ngtcp2_conn_stat * cstat = & conn -> cstat ;
5344
5342
5345
5343
if (pktns -> tx .last_pkt_num < fr -> largest_ack ) {
5346
5344
return NGTCP2_ERR_PROTO ;
5347
5345
}
5348
5346
5349
- rv = ngtcp2_pkt_validate_ack (fr , conn -> local .settings .initial_pkt_num );
5350
- if (rv != 0 ) {
5351
- return rv ;
5352
- }
5353
-
5354
5347
ngtcp2_acktr_recv_ack (& pktns -> acktr , fr );
5355
5348
5356
5349
num_acked =
@@ -6561,6 +6554,13 @@ conn_recv_handshake_pkt(ngtcp2_conn *conn, const ngtcp2_path *path,
6561
6554
case NGTCP2_FRAME_ACK_ECN :
6562
6555
fr -> ack .ack_delay = 0 ;
6563
6556
fr -> ack .ack_delay_unscaled = 0 ;
6557
+
6558
+ rv =
6559
+ ngtcp2_pkt_validate_ack (& fr -> ack , conn -> local .settings .initial_pkt_num );
6560
+ if (rv != 0 ) {
6561
+ return rv ;
6562
+ }
6563
+
6564
6564
break ;
6565
6565
}
6566
6566
@@ -8715,6 +8715,13 @@ conn_recv_delayed_handshake_pkt(ngtcp2_conn *conn, const ngtcp2_pkt_info *pi,
8715
8715
case NGTCP2_FRAME_ACK_ECN :
8716
8716
fr -> ack .ack_delay = 0 ;
8717
8717
fr -> ack .ack_delay_unscaled = 0 ;
8718
+
8719
+ rv =
8720
+ ngtcp2_pkt_validate_ack (& fr -> ack , conn -> local .settings .initial_pkt_num );
8721
+ if (rv != 0 ) {
8722
+ return rv ;
8723
+ }
8724
+
8718
8725
break ;
8719
8726
}
8720
8727
@@ -9200,6 +9207,13 @@ static ngtcp2_ssize conn_recv_pkt(ngtcp2_conn *conn, const ngtcp2_path *path,
9200
9207
assert (conn -> remote .transport_params );
9201
9208
assign_recved_ack_delay_unscaled (
9202
9209
& fr -> ack , conn -> remote .transport_params -> ack_delay_exponent );
9210
+
9211
+ rv =
9212
+ ngtcp2_pkt_validate_ack (& fr -> ack , conn -> local .settings .initial_pkt_num );
9213
+ if (rv != 0 ) {
9214
+ return rv ;
9215
+ }
9216
+
9203
9217
break ;
9204
9218
}
9205
9219
0 commit comments