From: Pauli Date: Mon, 22 Mar 2021 01:47:02 +0000 (+1000) Subject: apps: fix coverity 271258: improper use of negative value X-Git-Tag: openssl-3.0.0-alpha14~164 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5a14bd153a9c725c3b7b1e02920dc36052320b5b;p=thirdparty%2Fopenssl.git apps: fix coverity 271258: improper use of negative value Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/14638) --- diff --git a/apps/s_time.c b/apps/s_time.c index 386a81a78ef..60861642f54 100644 --- a/apps/s_time.c +++ b/apps/s_time.c @@ -127,7 +127,7 @@ int s_time_main(int argc, char **argv) int maxtime = SECONDS, nConn = 0, perform = 3, ret = 1, i, st_bugs = 0; long bytes_read = 0, finishtime = 0; OPTION_CHOICE o; - int min_version = 0, max_version = 0, ver, buf_len; + int min_version = 0, max_version = 0, ver, buf_len, fd; size_t buf_size; meth = TLS_client_method(); @@ -346,7 +346,8 @@ int s_time_main(int argc, char **argv) continue; } SSL_set_shutdown(scon, SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN); - BIO_closesocket(SSL_get_fd(scon)); + if ((fd = SSL_get_fd(scon)) >= 0) + BIO_closesocket(fd); nConn = 0; totalTime = 0.0; @@ -373,7 +374,8 @@ int s_time_main(int argc, char **argv) bytes_read += i; } SSL_set_shutdown(scon, SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN); - BIO_closesocket(SSL_get_fd(scon)); + if ((fd = SSL_get_fd(scon)) >= 0) + BIO_closesocket(fd); nConn += 1; if (SSL_session_reused(scon)) {