[PATCH] 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
Sat Nov 26 14:55:55 UTC 2016


Review at  https://gerrit.osmocom.org/1334

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(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/34/1334/1

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: newchange
Gerrit-Change-Id: Id962821c71b3a1c4c01c1131eb809b8ec8eaa062
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>



More information about the gerrit-log mailing list