naccyde / rpms / iproute

Forked from rpms/iproute 9 months ago
Clone

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

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