naccyde / rpms / iproute

Forked from rpms/iproute 7 months ago
Clone

Blame SOURCES/0099-devlink-Check-return-code-of-strslashrsplit.patch

36cfb7
From ea11b95042171f254fe0127ea0f1f2786d81dc83 Mon Sep 17 00:00:00 2001
36cfb7
From: Andrea Claudi <aclaudi@redhat.com>
36cfb7
Date: Mon, 29 Apr 2019 20:08:07 +0200
36cfb7
Subject: [PATCH] devlink: Check return code of strslashrsplit()
36cfb7
36cfb7
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1465646
36cfb7
Upstream Status: iproute2.git commit 6e33f7b0f6e04
36cfb7
36cfb7
commit 6e33f7b0f6e04dd46bea24c3ab28d61e54625dd7
36cfb7
Author: Phil Sutter <phil@nwl.cc>
36cfb7
Date:   Mon Aug 21 18:36:52 2017 +0200
36cfb7
36cfb7
    devlink: Check return code of strslashrsplit()
36cfb7
36cfb7
    This function shouldn't fail because all callers of
36cfb7
    __dl_argv_handle_port() make sure the passed string contains enough
36cfb7
    slashes already, but better make sure if this changes in future the
36cfb7
    function won't access uninitialized data.
36cfb7
36cfb7
    Signed-off-by: Phil Sutter <phil@nwl.cc>
36cfb7
---
36cfb7
 devlink/devlink.c | 16 ++++++++++++----
36cfb7
 1 file changed, 12 insertions(+), 4 deletions(-)
36cfb7
36cfb7
diff --git a/devlink/devlink.c b/devlink/devlink.c
36cfb7
index ae295b5632e8c..082eeafa1146a 100644
36cfb7
--- a/devlink/devlink.c
36cfb7
+++ b/devlink/devlink.c
36cfb7
@@ -576,18 +576,26 @@ static int __dl_argv_handle_port(char *str,
36cfb7
 				 char **p_bus_name, char **p_dev_name,
36cfb7
 				 uint32_t *p_port_index)
36cfb7
 {
36cfb7
-	char *handlestr = handlestr;
36cfb7
-	char *portstr = portstr;
36cfb7
+	char *handlestr;
36cfb7
+	char *portstr;
36cfb7
 	int err;
36cfb7
 
36cfb7
-	strslashrsplit(str, &handlestr, &portstr);
36cfb7
+	err = strslashrsplit(str, &handlestr, &portstr);
36cfb7
+	if (err) {
36cfb7
+		pr_err("Port identification \"%s\" is invalid\n", str);
36cfb7
+		return err;
36cfb7
+	}
36cfb7
 	err = strtouint32_t(portstr, p_port_index);
36cfb7
 	if (err) {
36cfb7
 		pr_err("Port index \"%s\" is not a number or not within range\n",
36cfb7
 		       portstr);
36cfb7
 		return err;
36cfb7
 	}
36cfb7
-	strslashrsplit(handlestr, p_bus_name, p_dev_name);
36cfb7
+	err = strslashrsplit(handlestr, p_bus_name, p_dev_name);
36cfb7
+	if (err) {
36cfb7
+		pr_err("Port identification \"%s\" is invalid\n", str);
36cfb7
+		return err;
36cfb7
+	}
36cfb7
 	return 0;
36cfb7
 }
36cfb7
 
36cfb7
-- 
e138d9
2.21.0
36cfb7