zebra: reject ingress packets that are too large

There may be logic to prevent this ever happening earlier in the network
read path, but it doesn't hurt to double check it here, because clearly
deeper paths rely on this being the case.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
This commit is contained in:
Quentin Young 2020-01-03 21:22:44 -05:00
parent ab12ca856c
commit aa8cb96489

View File

@ -2597,6 +2597,14 @@ void zserv_handle_commands(struct zserv *client, struct stream *msg)
struct zmsghdr hdr; struct zmsghdr hdr;
struct zebra_vrf *zvrf; struct zebra_vrf *zvrf;
if (STREAM_READABLE(msg) > ZEBRA_MAX_PACKET_SIZ) {
if (IS_ZEBRA_DEBUG_PACKET && IS_ZEBRA_DEBUG_RECV)
zlog_debug(
"ZAPI message is %zu bytes long but the maximum packet size is %u; dropping",
STREAM_READABLE(msg), ZEBRA_MAX_PACKET_SIZ);
return;
}
zapi_parse_header(msg, &hdr); zapi_parse_header(msg, &hdr);
if (IS_ZEBRA_DEBUG_PACKET && IS_ZEBRA_DEBUG_RECV) if (IS_ZEBRA_DEBUG_PACKET && IS_ZEBRA_DEBUG_RECV)