<div dir="auto">Ping :-)</div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 17 Sep 2021 at 21:34, Job Snijders <<a href="mailto:job@fastly.com">job@fastly.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I've aligned the text that is locally logged with the encapsulated error<br>
message sent to the broken RPKI cache. Also fixed a compiler warning<br>
that snuck into my previous patch: now passing the correct pointer<br>
(hton_pdu) to rpki_send_error_pdu().<br>
<br>
Kind regards,<br>
<br>
Job<br>
<br>
diff --git proto/rpki/packets.c proto/rpki/packets.c<br>
index dd11f997..7a1eeb0f 100644<br>
--- proto/rpki/packets.c<br>
+++ proto/rpki/packets.c<br>
@@ -737,6 +737,30 @@ rpki_handle_prefix_pdu(struct rpki_cache *cache, const struct pdu_header *pdu)<br>
net_addr_union addr = {};<br>
rpki_prefix_pdu_2_net_addr(pdu, &addr);<br>
<br>
+ if (type == IPV4_PREFIX) {<br>
+ if (addr.roa4.max_pxlen < addr.roa4.pxlen<br>
+ || addr.roa4.max_pxlen > IP4_MAX_PREFIX_LENGTH<br>
+ || addr.roa4.pxlen > IP4_MAX_PREFIX_LENGTH) {<br>
+ RPKI_WARN(cache->p, "Received corrupt packet from RPKI cache server: invalid pxlen or max_pxlen");<br>
+ byte tmp[pdu->len];<br>
+ const struct pdu_header *hton_pdu = rpki_pdu_back_to_network_byte_order((void *) tmp, (const void *) pdu);<br>
+ rpki_send_error_pdu(cache, CORRUPT_DATA, pdu->len, hton_pdu, "Corrupted PDU: invalid pxlen or max_pxlen");<br>
+ rpki_cache_change_state(cache, RPKI_CS_ERROR_FATAL);<br>
+ return RPKI_ERROR;<br>
+ }<br>
+ } else {<br>
+ if (addr.roa6.max_pxlen < addr.roa6.pxlen<br>
+ || addr.roa6.max_pxlen > IP6_MAX_PREFIX_LENGTH<br>
+ || addr.roa6.pxlen > IP6_MAX_PREFIX_LENGTH) {<br>
+ RPKI_WARN(cache->p, "Received corrupt packet from RPKI cache server: invalid pxlen or max_pxlen");<br>
+ byte tmp[pdu->len];<br>
+ const struct pdu_header *hton_pdu = rpki_pdu_back_to_network_byte_order((void *) tmp, (const void *) pdu);<br>
+ rpki_send_error_pdu(cache, CORRUPT_DATA, pdu->len, hton_pdu, "Corrupted PDU: invalid pxlen or max_pxlen");<br>
+ rpki_cache_change_state(cache, RPKI_CS_ERROR_FATAL);<br>
+ return RPKI_ERROR;<br>
+ }<br>
+ }<br>
+<br>
if (cf->ignore_max_length)<br>
{<br>
if (type == IPV4_PREFIX)<br>
</blockquote></div></div>