DPDK patches and discussions
 help / color / mirror / Atom feed
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 5/5] telemetry: fix buffer overrun if max bytes read
Date: Tue, 12 May 2020 16:29:02 +0100	[thread overview]
Message-ID: <20200512152902.70211-6-ciara.power@intel.com> (raw)
In-Reply-To: <20200512152902.70211-1-ciara.power@intel.com>

If 1024 bytes were received over the socket, this caused
buffer_recvf[bytes] to overrun the array. The size of the buffer - 1 is
now passed to the read function.

Coverity issue: 358442
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 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/librte_telemetry/telemetry_legacy.c b/lib/librte_telemetry/telemetry_legacy.c
index 2de9021349..a341fe4ebd 100644
--- a/lib/librte_telemetry/telemetry_legacy.c
+++ b/lib/librte_telemetry/telemetry_legacy.c
@@ -217,7 +217,7 @@ legacy_client_handler(void *sock_id)
 	int ret;
 	char buffer_recv[BUF_SIZE];
 	/* receive data is not null terminated */
-	int bytes = read(s, buffer_recv, sizeof(buffer_recv));
+	int bytes = read(s, buffer_recv, sizeof(buffer_recv) - 1);
 
 	while (bytes > 0) {
 		buffer_recv[bytes] = 0;
@@ -234,7 +234,7 @@ legacy_client_handler(void *sock_id)
 			if (ret < 0)
 				printf("\nCould not send error response\n");
 		}
-		bytes = read(s, buffer_recv, sizeof(buffer_recv));
+		bytes = read(s, buffer_recv, sizeof(buffer_recv) - 1);
 	}
 	close(s);
 	return NULL;
-- 
2.17.1


  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 ` [dpdk-dev] [PATCH 2/5] telemetry: fix error checking for strchr function Ciara Power
2020-05-18 14:52   ` 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 ` Ciara Power [this message]
2020-05-18 14:53   ` [dpdk-dev] [PATCH 5/5] telemetry: fix buffer overrun if max bytes read 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-6-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).