Skip to content

Commit e2f2442

Browse files
rx_session_should_admit(): check protocol version
1 parent 4e3c225 commit e2f2442

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

libcanard/canard.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1378,7 +1378,7 @@ static void rx_session_record_admission(rx_session_t* const ses,
13781378
const canard_us_t ts,
13791379
const byte_t iface_index)
13801380
{
1381-
ses->seqno_frontier[priority] = rx_seqno_pack(seqno); // nothing older than this at this priority from now on
1381+
ses->seqno_frontier[priority] = rx_seqno_pack(seqno); // nothing older than this at this & higher prio from now on
13821382
ses->last_admitted_start_ts = ts;
13831383
ses->iface_index = iface_index;
13841384
}
@@ -1414,6 +1414,11 @@ static bool rx_session_should_admit(const rx_session_t* const ses,
14141414
return (slot != NULL) && (slot->transfer_id == (seqno & CANARD_TRANSFER_ID_MAX)) &&
14151415
(slot->iface_index == iface_index) && (slot->expected_toggle == toggle);
14161416
}
1417+
// This is a start frame, but before we allocate new state for it, we must ensure that it is of the correct version.
1418+
const bool start_toggle = kind_is_v1(ses->owner->kind) ? 1 : 0;
1419+
if (toggle != start_toggle) {
1420+
return false; // Wrong protocol version.
1421+
}
14171422
// Duplicate start frames do not require special treatment because a duplicate frame can only follow the original
14181423
// without any frames belonging to the same transfer in between (see the assumptions). If we get a duplicate start,
14191424
// with a nonzero TID timeout it will be rejected as not-new; even if the timeout is zero, accepting the duplicate

0 commit comments

Comments
 (0)