Blame SOURCES/0050-iproute-Abort-if-nexthop-cannot-be-parsed.patch

36cfb7
From d80837df37cb8897769f87f7a2034a9653168221 Mon Sep 17 00:00:00 2001
36cfb7
From: Phil Sutter <psutter@redhat.com>
36cfb7
Date: Thu, 21 Feb 2019 14:38:57 +0100
36cfb7
Subject: [PATCH] iproute: Abort if nexthop cannot be parsed
36cfb7
36cfb7
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1624656
36cfb7
Upstream Status: iproute2.git commit ee53b42fd8b0b
36cfb7
36cfb7
commit ee53b42fd8b0b0cdb857d0f5bf7467e22a3457d9
36cfb7
Author: Jakub Sitnicki <jkbs@redhat.com>
36cfb7
Date:   Wed Apr 11 11:43:11 2018 +0200
36cfb7
36cfb7
    iproute: Abort if nexthop cannot be parsed
36cfb7
36cfb7
    Attempt to add a multipath route where a nexthop definition refers to a
36cfb7
    non-existent device causes 'ip' to crash and burn due to stack buffer
36cfb7
    overflow:
36cfb7
36cfb7
      # ip -6 route add fd00::1/64 nexthop dev fake1
36cfb7
      Cannot find device "fake1"
36cfb7
      Cannot find device "fake1"
36cfb7
      Cannot find device "fake1"
36cfb7
      ...
36cfb7
      Segmentation fault (core dumped)
36cfb7
36cfb7
    Don't ignore errors from the helper routine that parses the nexthop
36cfb7
    definition, and abort immediately if parsing fails.
36cfb7
36cfb7
    Signed-off-by: Jakub Sitnicki <jkbs@redhat.com>
36cfb7
---
36cfb7
 ip/iproute.c | 5 ++++-
36cfb7
 1 file changed, 4 insertions(+), 1 deletion(-)
36cfb7
36cfb7
diff --git a/ip/iproute.c b/ip/iproute.c
36cfb7
index 35fdce8..759032d 100644
36cfb7
--- a/ip/iproute.c
36cfb7
+++ b/ip/iproute.c
36cfb7
@@ -817,7 +817,10 @@ static int parse_nexthops(struct nlmsghdr *n, struct rtmsg *r,
36cfb7
 		memset(rtnh, 0, sizeof(*rtnh));
36cfb7
 		rtnh->rtnh_len = sizeof(*rtnh);
36cfb7
 		rta->rta_len += rtnh->rtnh_len;
36cfb7
-		parse_one_nh(n, r, rta, rtnh, &argc, &argv);
36cfb7
+		if (parse_one_nh(n, r, rta, rtnh, &argc, &argv)) {
36cfb7
+			fprintf(stderr, "Error: cannot parse nexthop\n");
36cfb7
+			exit(-1);
36cfb7
+		}
36cfb7
 		rtnh = RTNH_NEXT(rtnh);
36cfb7
 	}
36cfb7
 
36cfb7
-- 
36cfb7
1.8.3.1
36cfb7