]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
RPKI: Fix PDU length check
authorOndrej Zajicek <santiago@crfreenet.org>
Tue, 26 Nov 2024 16:46:27 +0000 (17:46 +0100)
committerOndrej Zajicek <santiago@crfreenet.org>
Tue, 26 Nov 2024 16:52:51 +0000 (17:52 +0100)
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.

proto/rpki/packets.c

index c26c46d1206362bbf95ac38dc4a32e69efdccb9f..6d2ec9d1fdaa1587dda9140e8c6c94706a38c417 100644 (file)
@@ -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;
   }