[MERGED] libosmo-netif[master]: stream-client: check read() return value before using it as ...

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Thu Dec 1 14:54:52 UTC 2016


Harald Welte has submitted this change and it was merged.

Change subject: stream-client: check read() return value before using it as length input to memcpy
......................................................................


stream-client: check read() return value before using it as length input to memcpy

Change-Id: Id962821c71b3a1c4c01c1131eb809b8ec8eaa062
Fixes: Coverity CID 57859
---
M examples/stream-client.c
1 file changed, 2 insertions(+), 1 deletion(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/examples/stream-client.c b/examples/stream-client.c
index c54db02..b0aea5e 100644
--- a/examples/stream-client.c
+++ b/examples/stream-client.c
@@ -72,8 +72,9 @@
 	int ret;
 
 	ret = read(STDIN_FILENO, buf, sizeof(buf));
-
 	LOGP(DSTREAMTEST, LOGL_NOTICE, "read %d byte from keyboard\n", ret);
+	if (ret < 0)
+		return ret;
 
 	msg = msgb_alloc(1024, "STREAMCLIENT/test");
 	if (msg == NULL) {

-- 
To view, visit https://gerrit.osmocom.org/1334
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Id962821c71b3a1c4c01c1131eb809b8ec8eaa062
Gerrit-PatchSet: 2
Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list