summaryrefslogtreecommitdiff
path: root/ssh-keyscan.c
diff options
context:
space:
mode:
Diffstat (limited to 'ssh-keyscan.c')
-rw-r--r--ssh-keyscan.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/ssh-keyscan.c b/ssh-keyscan.c
index 2ed041559..5de0508d0 100644
--- a/ssh-keyscan.c
+++ b/ssh-keyscan.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-keyscan.c,v 1.126 2019/01/26 22:35:01 djm Exp $ */ 1/* $OpenBSD: ssh-keyscan.c,v 1.130 2019/09/06 05:23:55 djm Exp $ */
2/* 2/*
3 * Copyright 1995, 1996 by David Mazieres <dm@lcs.mit.edu>. 3 * Copyright 1995, 1996 by David Mazieres <dm@lcs.mit.edu>.
4 * 4 *
@@ -19,7 +19,9 @@
19#include <netinet/in.h> 19#include <netinet/in.h>
20#include <arpa/inet.h> 20#include <arpa/inet.h>
21 21
22#ifdef WITH_OPENSSL
22#include <openssl/bn.h> 23#include <openssl/bn.h>
24#endif
23 25
24#include <netdb.h> 26#include <netdb.h>
25#include <errno.h> 27#include <errno.h>
@@ -122,7 +124,7 @@ fdlim_get(int hard)
122#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE) 124#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE)
123 struct rlimit rlfd; 125 struct rlimit rlfd;
124 126
125 if (getrlimit(RLIMIT_NOFILE, &rlfd) < 0) 127 if (getrlimit(RLIMIT_NOFILE, &rlfd) == -1)
126 return (-1); 128 return (-1);
127 if ((hard ? rlfd.rlim_max : rlfd.rlim_cur) == RLIM_INFINITY) 129 if ((hard ? rlfd.rlim_max : rlfd.rlim_cur) == RLIM_INFINITY)
128 return SSH_SYSFDMAX; 130 return SSH_SYSFDMAX;
@@ -143,10 +145,10 @@ fdlim_set(int lim)
143 if (lim <= 0) 145 if (lim <= 0)
144 return (-1); 146 return (-1);
145#if defined(HAVE_SETRLIMIT) && defined(RLIMIT_NOFILE) 147#if defined(HAVE_SETRLIMIT) && defined(RLIMIT_NOFILE)
146 if (getrlimit(RLIMIT_NOFILE, &rlfd) < 0) 148 if (getrlimit(RLIMIT_NOFILE, &rlfd) == -1)
147 return (-1); 149 return (-1);
148 rlfd.rlim_cur = lim; 150 rlfd.rlim_cur = lim;
149 if (setrlimit(RLIMIT_NOFILE, &rlfd) < 0) 151 if (setrlimit(RLIMIT_NOFILE, &rlfd) == -1)
150 return (-1); 152 return (-1);
151#elif defined (HAVE_SETDTABLESIZE) 153#elif defined (HAVE_SETDTABLESIZE)
152 setdtablesize(lim); 154 setdtablesize(lim);
@@ -233,7 +235,12 @@ keygrab_ssh2(con *c)
233 break; 235 break;
234 case KT_RSA: 236 case KT_RSA:
235 myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = get_cert ? 237 myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = get_cert ?
236 "ssh-rsa-cert-v01@openssh.com" : "ssh-rsa"; 238 "rsa-sha2-512-cert-v01@openssh.com,"
239 "rsa-sha2-256-cert-v01@openssh.com,"
240 "ssh-rsa-cert-v01@openssh.com" :
241 "rsa-sha2-512,"
242 "rsa-sha2-256,"
243 "ssh-rsa";
237 break; 244 break;
238 case KT_ED25519: 245 case KT_ED25519:
239 myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = get_cert ? 246 myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = get_cert ?
@@ -343,13 +350,13 @@ tcpconnect(char *host)
343 } 350 }
344 for (ai = aitop; ai; ai = ai->ai_next) { 351 for (ai = aitop; ai; ai = ai->ai_next) {
345 s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); 352 s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
346 if (s < 0) { 353 if (s == -1) {
347 error("socket: %s", strerror(errno)); 354 error("socket: %s", strerror(errno));
348 continue; 355 continue;
349 } 356 }
350 if (set_nonblock(s) == -1) 357 if (set_nonblock(s) == -1)
351 fatal("%s: set_nonblock(%d)", __func__, s); 358 fatal("%s: set_nonblock(%d)", __func__, s);
352 if (connect(s, ai->ai_addr, ai->ai_addrlen) < 0 && 359 if (connect(s, ai->ai_addr, ai->ai_addrlen) == -1 &&
353 errno != EINPROGRESS) 360 errno != EINPROGRESS)
354 error("connect (`%s'): %s", host, strerror(errno)); 361 error("connect (`%s'): %s", host, strerror(errno));
355 else 362 else
@@ -656,7 +663,6 @@ main(int argc, char **argv)
656 extern int optind; 663 extern int optind;
657 extern char *optarg; 664 extern char *optarg;
658 665
659 ssh_malloc_init(); /* must be called before any mallocs */
660 __progname = ssh_get_progname(argv[0]); 666 __progname = ssh_get_progname(argv[0]);
661 seed_rng(); 667 seed_rng();
662 TAILQ_INIT(&tq); 668 TAILQ_INIT(&tq);