From: Ciara Power <ciara.power@intel.com>
To: bruce.richardson@intel.com
Cc: dev@dpdk.org, Ciara Power <ciara.power@intel.com>
Subject: [dpdk-dev] [PATCH 2/5] telemetry: fix error checking for strchr function
Date: Tue, 12 May 2020 16:28:59 +0100 [thread overview]
Message-ID: <20200512152902.70211-3-ciara.power@intel.com> (raw)
In-Reply-To: <20200512152902.70211-1-ciara.power@intel.com>
The strchr function return was not being checked which could lead to
NULL deferencing later in the function.
Coverity issue: 358438
Coverity issue: 358445
Fixes: b80fe1805eee ("telemetry: introduce backward compatibility")
Cc: ciara.power@intel.com
Signed-off-by: Ciara Power <ciara.power@intel.com>
---
lib/librte_telemetry/telemetry_legacy.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/lib/librte_telemetry/telemetry_legacy.c b/lib/librte_telemetry/telemetry_legacy.c
index 8e24eb4cb9..10b575adfd 100644
--- a/lib/librte_telemetry/telemetry_legacy.c
+++ b/lib/librte_telemetry/telemetry_legacy.c
@@ -82,8 +82,16 @@ register_client(const char *cmd __rte_unused, const char *params,
int fd;
struct sockaddr_un addrs;
+ if (!strchr(params, ':')) {
+ fprintf(stderr, "Invalid data\n");
+ return -1;
+ }
strlcpy(data, strchr(params, ':'), sizeof(data));
memcpy(data, &data[strlen(":\"")], strlen(data));
+ if (!strchr(data, '\"')) {
+ fprintf(stderr, "Invalid client data\n");
+ return -1;
+ }
*strchr(data, '\"') = 0;
fd = socket(AF_UNIX, SOCK_SEQPACKET, 0);
@@ -178,6 +186,8 @@ parse_client_request(char *buffer, int buf_len, int s)
if (!strchr(data_ptr, '{'))
data_sep = data_ptr[strlen(callbacks[i].data)];
else {
+ if (!strchr(data_ptr, '}'))
+ return -EINVAL;
char *data_end = strchr(data_ptr, '}');
data = data_ptr + strlen(DATA_REQ_LABEL);
data_sep = data_end[1];
--
2.17.1
next prev parent reply other threads:[~2020-05-12 15:31 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-12 15:28 [dpdk-dev] [PATCH 0/5] small fixes for telemetry rework Ciara Power
2020-05-12 15:28 ` [dpdk-dev] [PATCH 1/5] telemetry: keep telemetry threads separate from data plane Ciara Power
2020-05-18 14:52 ` Laatz, Kevin
2020-05-12 15:28 ` Ciara Power [this message]
2020-05-18 14:52 ` [dpdk-dev] [PATCH 2/5] telemetry: fix error checking for strchr function Laatz, Kevin
2020-05-12 15:29 ` [dpdk-dev] [PATCH 3/5] telemetry: fix closing socket fd on error Ciara Power
2020-05-18 14:52 ` Laatz, Kevin
2020-05-12 15:29 ` [dpdk-dev] [PATCH 4/5] telemetry: fix checking error return for socket creation Ciara Power
2020-05-18 14:53 ` Laatz, Kevin
2020-05-12 15:29 ` [dpdk-dev] [PATCH 5/5] telemetry: fix buffer overrun if max bytes read Ciara Power
2020-05-18 14:53 ` Laatz, Kevin
2020-05-19 12:31 ` [dpdk-dev] [PATCH 0/5] small fixes for telemetry rework Thomas Monjalon
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=20200512152902.70211-3-ciara.power@intel.com \
--to=ciara.power@intel.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.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).