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