Skip to content

Commit 12d39dd

Browse files
yosuke-wolfsslejohnstown
authored andcommitted
examples/client: guard rxBuf indexing against negative stream_read error
1 parent 2d0ef5a commit 12d39dd

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

examples/client/client.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,8 +1170,10 @@ THREAD_RETURN WOLFSSH_THREAD client_test(void* args)
11701170
}
11711171
} while (ret == WS_WANT_READ || ret == WS_WANT_WRITE);
11721172

1173-
rxBuf[ret] = '\0';
1174-
printf("Server said: %s\n", rxBuf);
1173+
if (ret > 0 && ret < (int)sizeof(rxBuf)) {
1174+
rxBuf[ret] = '\0';
1175+
printf("Server said: %s\n", rxBuf);
1176+
}
11751177

11761178
#if defined(WOLFSSL_PTHREADS) && defined(WOLFSSL_TEST_GLOBAL_REQ)
11771179
sleep(10);

0 commit comments

Comments
 (0)