From 382580701b20c2047f2ade8d5e952fe0fbd0951a Mon Sep 17 00:00:00 2001 From: Phil Sorber Date: Tue, 29 Oct 2019 11:24:10 -0600 Subject: [PATCH] Issue #4294: Handle return value of SSL_write() properly. --- tests/gold_tests/tls/ssl-post.c | 6 +++--- tools/http_load/http_load.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/gold_tests/tls/ssl-post.c b/tests/gold_tests/tls/ssl-post.c index 35ec0092874..dcb7ace554e 100644 --- a/tests/gold_tests/tls/ssl-post.c +++ b/tests/gold_tests/tls/ssl-post.c @@ -134,15 +134,15 @@ spawn_same_session_send(void *arg) ret = select(sfd + 1, &reads, &writes, NULL, NULL); if (FD_ISSET(sfd, &reads) || FD_ISSET(sfd, &writes)) { ret = write_ret = SSL_write(ssl, req_buf, strlen(req_buf)); - if (write_ret >= 0) + if (write_ret > 0) post_write_ret = SSL_write(ssl, post_buf, sizeof(post_buf)); } } - while (write_ret < 0) { + while (write_ret <= 0) { write_ret = SSL_write(ssl, req_buf, strlen(req_buf)); } - while (post_write_ret < 0) { + while (post_write_ret <= 0) { post_write_ret = SSL_write(ssl, post_buf, sizeof(post_buf)); } diff --git a/tools/http_load/http_load.c b/tools/http_load/http_load.c index da8c74c6bff..59bd5dd6bae 100644 --- a/tools/http_load/http_load.c +++ b/tools/http_load/http_load.c @@ -1098,7 +1098,7 @@ start_socket(int url_num, int cnum, struct timeval *nowP) r = SSL_write(connections[cnum].ssl, urls[url_num].buf, urls[url_num].buf_bytes); else r = write(connections[cnum].conn_fd, urls[url_num].buf, urls[url_num].buf_bytes); - if (r < 0) { + if (r <= 0) { perror(urls[url_num].url_str); connections[cnum].reusable = 0; close_connection(cnum); @@ -1216,7 +1216,7 @@ handle_connect(int cnum, struct timeval *nowP, int double_check) r = SSL_write(connections[cnum].ssl, urls[url_num].buf, urls[url_num].buf_bytes); else r = write(connections[cnum].conn_fd, urls[url_num].buf, urls[url_num].buf_bytes); - if (r < 0) { + if (r <= 0) { perror(urls[url_num].url_str); connections[cnum].reusable = 0; close_connection(cnum);