summaryrefslogtreecommitdiff
path: root/usr.bin/ssh/ssh.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@cvs.openbsd.org>2020-11-12 22:38:58 +0000
committerDarren Tucker <dtucker@cvs.openbsd.org>2020-11-12 22:38:58 +0000
commit9afd2fd866c77d3bd97768d0a4a785840d960654 (patch)
tree2501d2c1f5c890e1bb4a17f8f87c9980169c9ed2 /usr.bin/ssh/ssh.c
parent470eeffe70446b435c10b11dac7f6818b19553d5 (diff)
Prevent integer overflow when ridiculously large ConnectTimeout is
specified, capping the effective value (for most platforms) at 24 days. bz#3229, ok djm@
Diffstat (limited to 'usr.bin/ssh/ssh.c')
-rw-r--r--usr.bin/ssh/ssh.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/usr.bin/ssh/ssh.c b/usr.bin/ssh/ssh.c
index 775369694b1..5bcb47444ea 100644
--- a/usr.bin/ssh/ssh.c
+++ b/usr.bin/ssh/ssh.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh.c,v 1.541 2020/11/08 11:46:12 dtucker Exp $ */
+/* $OpenBSD: ssh.c,v 1.542 2020/11/12 22:38:57 dtucker Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -1502,7 +1502,10 @@ main(int ac, char **av)
cleanup_exit(255); /* resolve_host logs the error */
}
- timeout_ms = options.connection_timeout * 1000;
+ if (options.connection_timeout >= INT_MAX/1000)
+ timeout_ms = INT_MAX;
+ else
+ timeout_ms = options.connection_timeout * 1000;
/* Open a connection to the remote host. */
if (ssh_connect(ssh, host, host_arg, addrs, &hostaddr, options.port,