aboutsummaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2018-05-29 16:09:02 +0100
committerMatt Caswell <matt@openssl.org>2018-05-31 10:39:13 +0100
commit5f49783c12e9e6100075e50fe727ee2d5cc30445 (patch)
tree7e4c0c2ac6eb562bb91479e32a7a87946693e583 /apps
parentbdd5f12ea6b76fb133b152a3ca38a3c045be4de3 (diff)
downloadopenssl-5f49783c12e9e6100075e50fe727ee2d5cc30445.zip
openssl-5f49783c12e9e6100075e50fe727ee2d5cc30445.tar.gz
openssl-5f49783c12e9e6100075e50fe727ee2d5cc30445.tar.bz2
Don't call setsockopt with an invalid fd
This is probably a "should not happen" scenario, but better check anyway. Found by Coverity. Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/6373)
Diffstat (limited to 'apps')
-rw-r--r--apps/s_time.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/apps/s_time.c b/apps/s_time.c
index 5688f4f..82d40a5 100644
--- a/apps/s_time.c
+++ b/apps/s_time.c
@@ -389,11 +389,14 @@ static SSL *doConnection(SSL *scon, const char *host, SSL_CTX *ctx)
#if defined(SOL_SOCKET) && defined(SO_LINGER)
{
struct linger no_linger;
+ int fd;
no_linger.l_onoff = 1;
no_linger.l_linger = 0;
- (void) setsockopt(SSL_get_fd(serverCon), SOL_SOCKET, SO_LINGER,
- (char*)&no_linger, sizeof(no_linger));
+ fd = SSL_get_fd(serverCon);
+ if (fd >= 0)
+ (void)setsockopt(fd, SOL_SOCKET, SO_LINGER, (char*)&no_linger,
+ sizeof(no_linger));
}
#endif