From: Ondrej Zajicek Date: Tue, 26 Nov 2024 16:46:27 +0000 (+0100) Subject: RPKI: Fix PDU length check X-Git-Tag: v2.16~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fb919ac2a266aed53638ebc4f006c7ef48bb9e31;p=thirdparty%2Fbird.git RPKI: Fix PDU length check The END_OF_DATA PDU was extended in version 1, so it has different length in different versions. We should do the PDU length check according to its version. --- diff --git a/proto/rpki/packets.c b/proto/rpki/packets.c index c26c46d12..6d2ec9d1f 100644 --- a/proto/rpki/packets.c +++ b/proto/rpki/packets.c @@ -653,9 +653,13 @@ rpki_check_receive_packet(struct rpki_cache *cache, const struct pdu_header *pdu return RPKI_ERROR; } - if (pdu_len < min_pdu_size[pdu->type]) + uint min_pdu_length = min_pdu_size[pdu->type]; + if (pdu->type == END_OF_DATA && pdu->ver >= RPKI_VERSION_1) + min_pdu_length = sizeof(struct pdu_end_of_data_v1); + + if (pdu_len < min_pdu_length) { - rpki_send_error_pdu(cache, CORRUPT_DATA, pdu_len, pdu, "Received %s packet with %d bytes, but expected at least %d bytes", str_pdu_type(pdu->type), pdu_len, min_pdu_size[pdu->type]); + rpki_send_error_pdu(cache, CORRUPT_DATA, pdu_len, pdu, "Received %s packet with %u bytes, but expected at least %u bytes", str_pdu_type(pdu->type), pdu_len, min_pdu_length); return RPKI_ERROR; }