diff --git a/examples/client/client.c b/examples/client/client.c index 0702c22a3..a58067910 100644 --- a/examples/client/client.c +++ b/examples/client/client.c @@ -419,14 +419,14 @@ void client_test(void* args) if (CyaSSL_write(ssl, msg, msgSz) != msgSz) err_sys("SSL_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); if (sendGET) { /* get html */ 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); @@ -510,7 +510,7 @@ void client_test(void* args) #endif } - input = CyaSSL_read(sslResume, reply, sizeof(reply)); + input = CyaSSL_read(sslResume, reply, sizeof(reply)-1); if (input > 0) { reply[input] = 0; printf("Server resume response: %s\n", reply); diff --git a/examples/echoclient/echoclient.c b/examples/echoclient/echoclient.c index 51944d643..9f9ce0a85 100644 --- a/examples/echoclient/echoclient.c +++ b/examples/echoclient/echoclient.c @@ -39,7 +39,7 @@ void echoclient_test(void* args) int outCreated = 0; char msg[1024]; - char reply[1024]; + char reply[1024+1]; SSL_METHOD* method = 0; SSL_CTX* ctx = 0; @@ -148,7 +148,7 @@ void echoclient_test(void* args) while (sendSz) { int got; - if ( (got = SSL_read(ssl, reply, sizeof(reply))) > 0) { + if ( (got = SSL_read(ssl, reply, sizeof(reply)-1)) > 0) { reply[got] = 0; fputs(reply, fout); sendSz -= got; diff --git a/examples/echoserver/echoserver.c b/examples/echoserver/echoserver.c index d5c11405e..364527607 100644 --- a/examples/echoserver/echoserver.c +++ b/examples/echoserver/echoserver.c @@ -163,7 +163,7 @@ THREAD_RETURN CYASSL_THREAD echoserver_test(void* args) while (!shutDown) { CYASSL* ssl = 0; - char command[1024]; + char command[1024+1]; int echoSz = 0; int clientfd; int firstRead = 1; @@ -197,7 +197,7 @@ THREAD_RETURN CYASSL_THREAD echoserver_test(void* args) showPeer(ssl); #endif - while ( (echoSz = CyaSSL_read(ssl, command, sizeof(command))) > 0) { + while ( (echoSz = CyaSSL_read(ssl, command, sizeof(command)-1)) > 0) { if (firstRead == 1) { firstRead = 0; /* browser may send 1 byte 'G' to start */ diff --git a/examples/server/server.c b/examples/server/server.c index 7bf278805..fc22537ad 100644 --- a/examples/server/server.c +++ b/examples/server/server.c @@ -351,7 +351,7 @@ THREAD_RETURN CYASSL_THREAD server_test(void* args) #endif showPeer(ssl); - idx = SSL_read(ssl, input, sizeof(input)); + idx = SSL_read(ssl, input, sizeof(input)-1); if (idx > 0) { input[idx] = 0; printf("Client message: %s\n", input); diff --git a/mqx/cyassl_client/Sources/main.c b/mqx/cyassl_client/Sources/main.c index 7d04f9f3f..3938a87ac 100644 --- a/mqx/cyassl_client/Sources/main.c +++ b/mqx/cyassl_client/Sources/main.c @@ -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); diff --git a/tests/api.c b/tests/api.c index 7d5c417a9..d598b4e73 100644 --- a/tests/api.c +++ b/tests/api.c @@ -651,7 +651,7 @@ THREAD_RETURN CYASSL_THREAD test_server_nofail(void* args) return 0; } - idx = CyaSSL_read(ssl, input, sizeof(input)); + idx = CyaSSL_read(ssl, input, sizeof(input)-1); if (idx > 0) { input[idx] = 0; printf("Client message: %s\n", input); @@ -732,7 +732,7 @@ void test_client_nofail(void* args) return; } - input = CyaSSL_read(ssl, reply, sizeof(reply)); + input = CyaSSL_read(ssl, reply, sizeof(reply)-1); if (input > 0) { reply[input] = 0;