From: Phil Sutter <phil@nwl.cc>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: netdev@vger.kernel.org
Subject: [iproute PATCH v2 3/3] devlink: Check return code of strslashrsplit()
Date: Mon, 21 Aug 2017 18:36:52 +0200 [thread overview]
Message-ID: <20170821163652.23752-4-phil@nwl.cc> (raw)
In-Reply-To: <20170821163652.23752-1-phil@nwl.cc>
This function shouldn't fail because all callers of
__dl_argv_handle_port() make sure the passed string contains enough
slashes already, but better make sure if this changes in future the
function won't access uninitialized data.
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
devlink/devlink.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/devlink/devlink.c b/devlink/devlink.c
index f9bc16c350c40..de41a9f4aae10 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -526,18 +526,26 @@ static int __dl_argv_handle_port(char *str,
char **p_bus_name, char **p_dev_name,
uint32_t *p_port_index)
{
- char *handlestr = handlestr;
- char *portstr = portstr;
+ char *handlestr;
+ char *portstr;
int err;
- strslashrsplit(str, &handlestr, &portstr);
+ err = strslashrsplit(str, &handlestr, &portstr);
+ if (err) {
+ pr_err("Port identification \"%s\" is invalid\n", str);
+ return err;
+ }
err = strtouint32_t(portstr, p_port_index);
if (err) {
pr_err("Port index \"%s\" is not a number or not within range\n",
portstr);
return err;
}
- strslashrsplit(handlestr, p_bus_name, p_dev_name);
+ err = strslashrsplit(handlestr, p_bus_name, p_dev_name);
+ if (err) {
+ pr_err("Port identification \"%s\" is invalid\n", str);
+ return err;
+ }
return 0;
}
--
2.13.1
next prev parent reply other threads:[~2017-08-21 16:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-21 16:36 [iproute PATCH v2 0/3] Covscan: Fix for missing error checking Phil Sutter
2017-08-21 16:36 ` [iproute PATCH v2 1/3] iproute: Check mark value input Phil Sutter
2017-08-21 16:36 ` [iproute PATCH v2 2/3] iplink_vrf: Complain if main table is not found Phil Sutter
2017-08-21 16:36 ` Phil Sutter [this message]
2017-08-22 0:29 ` [iproute PATCH v2 0/3] Covscan: Fix for missing error checking Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170821163652.23752-4-phil@nwl.cc \
--to=phil@nwl.cc \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).