make sure example CyaSSL_read()s that fill buffer don't overrun by 1 byte if trying to output with null terminator

This commit is contained in:
toddouska
2013-02-08 11:21:48 -08:00
parent 44e0d7543c
commit 8ace08499b
6 changed files with 12 additions and 12 deletions

View File

@@ -214,13 +214,13 @@ void client_test(void) {
if (CyaSSL_write(ssl, msg, msgSz) != msgSz)
err_sys("CyaSSL_write() failed");
input = CyaSSL_read(ssl, reply, sizeof(reply));
input = CyaSSL_read(ssl, reply, sizeof(reply)-1);
if (input > 0) {
reply[input] = 0;
printf("Server response: %s\n", reply);
while(1) {
input = CyaSSL_read(ssl, reply, sizeof(reply));
input = CyaSSL_read(ssl, reply, sizeof(reply)-1);
if (input > 0) {
reply[input] = 0;
printf("%s\n", reply);