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

Change-Id: Id962821c71b3a1c4c01c1131eb809b8ec8eaa062
Fixes: Coverity CID 57859
This commit is contained in:
Harald Welte 2016-11-26 15:49:21 +01:00
parent a47c8a3f3f
commit e63f88146d
1 changed files with 2 additions and 1 deletions

View File

@ -72,8 +72,9 @@ static int kbd_cb(struct osmo_fd *fd, unsigned int what)
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) {