Blame SOURCES/0013-CVE-2022-37032.patch

8cf488
From ff6db1027f8f36df657ff2e5ea167773752537ed Mon Sep 17 00:00:00 2001
8cf488
From: Donald Sharp <sharpd@nvidia.com>
8cf488
Date: Thu, 21 Jul 2022 08:11:58 -0400
8cf488
Subject: [PATCH] bgpd: Make sure hdr length is at a minimum of what is
8cf488
 expected
8cf488
8cf488
Ensure that if the capability length specified is enough data.
8cf488
8cf488
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
8cf488
---
8cf488
 bgpd/bgp_packet.c | 8 ++++++++
8cf488
 1 file changed, 8 insertions(+)
8cf488
8cf488
diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c
8cf488
index dbf6c0b2e99..45752a8ab6d 100644
8cf488
--- a/bgpd/bgp_packet.c
8cf488
+++ b/bgpd/bgp_packet.c
8cf488
@@ -2620,6 +2620,14 @@ static int bgp_capability_msg_parse(struct peer *peer, uint8_t *pnt,
8cf488
 				"%s CAPABILITY has action: %d, code: %u, length %u",
8cf488
 				peer->host, action, hdr->code, hdr->length);
8cf488
 
8cf488
+		if (hdr->length < sizeof(struct capability_mp_data)) {
8cf488
+			zlog_info(
8cf488
+				"%pBP Capability structure is not properly filled out, expected at least %zu bytes but header length specified is %d",
8cf488
+				peer, sizeof(struct capability_mp_data),
8cf488
+				hdr->length);
8cf488
+			return BGP_Stop;
8cf488
+		}
8cf488
+
8cf488
 		/* Capability length check. */
8cf488
 		if ((pnt + hdr->length + 3) > end) {
8cf488
 			zlog_info("%s Capability length error", peer->host);