]> andersk Git - openssh.git/blobdiff - ssh-keyscan.c
- stevesk@cvs.openbsd.org 2006/07/22 20:48:23
[openssh.git] / ssh-keyscan.c
index 6915102ddf3ba7f7665edf96141962db18857f30..30df75166147cb0836c815ee627a5a92b35073ff 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenBSD: ssh-keyscan.c,v 1.69 2006/07/22 20:48:23 stevesk Exp $ */
 /*
  * Copyright 1995, 1996 by David Mazieres <dm@lcs.mit.edu>.
  *
@@ -7,13 +8,21 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: ssh-keyscan.c,v 1.57 2005/10/30 04:01:03 djm Exp $");
-
 #include "openbsd-compat/sys-queue.h"
+#include <sys/resource.h>
 
 #include <openssl/bn.h>
 
+#if defined(HAVE_NETDB_H)
+# include <netdb.h>
+#endif
+#include <errno.h>
+#include <stdarg.h>
 #include <setjmp.h>
+#include <string.h>
+#include <unistd.h>
+
 #include "xmalloc.h"
 #include "ssh.h"
 #include "ssh1.h"
@@ -54,7 +63,7 @@ int maxfd;
 
 extern char *__progname;
 fd_set *read_wait;
-size_t read_wait_size;
+size_t read_wait_nfdset;
 int ncon;
 int nonfatal_fatal = 0;
 jmp_buf kexjmp;
@@ -128,7 +137,7 @@ Linebuf_alloc(const char *filename, void (*errfun) (const char *,...))
                lb->stream = stdin;
        }
 
-       if (!(lb->buf = malloc(lb->size = LINEBUF_SIZE))) {
+       if (!(lb->buf = malloc((lb->size = LINEBUF_SIZE)))) {
                if (errfun)
                        (*errfun) ("linebuf (%s): malloc failed\n", lb->filename);
                xfree(lb);
@@ -350,6 +359,7 @@ keygrab_ssh2(con *c)
        c->c_kex->kex[KEX_DH_GRP1_SHA1] = kexdh_client;
        c->c_kex->kex[KEX_DH_GRP14_SHA1] = kexdh_client;
        c->c_kex->kex[KEX_DH_GEX_SHA1] = kexgex_client;
+       c->c_kex->kex[KEX_DH_GEX_SHA256] = kexgex_client;
        c->c_kex->verify_host_key = hostjump;
 
        if (!(j = setjmp(kexjmp))) {
@@ -602,7 +612,6 @@ conread(int s)
                        keyprint(c, keygrab_ssh1(c));
                        confree(s);
                        return;
-                       break;
                default:
                        fatal("conread: invalid status %d", c->c_status);
                        break;
@@ -634,10 +643,10 @@ conloop(void)
        } else
                seltime.tv_sec = seltime.tv_usec = 0;
 
-       r = xmalloc(read_wait_size);
-       memcpy(r, read_wait, read_wait_size);
-       e = xmalloc(read_wait_size);
-       memcpy(e, read_wait, read_wait_size);
+       r = xcalloc(read_wait_nfdset, sizeof(fd_mask));
+       e = xcalloc(read_wait_nfdset, sizeof(fd_mask));
+       memcpy(r, read_wait, read_wait_nfdset * sizeof(fd_mask));
+       memcpy(e, read_wait, read_wait_nfdset * sizeof(fd_mask));
 
        while (select(maxfd, r, NULL, e, &seltime) == -1 &&
            (errno == EAGAIN || errno == EINTR))
@@ -804,12 +813,10 @@ main(int argc, char **argv)
                fatal("%s: not enough file descriptors", __progname);
        if (maxfd > fdlim_get(0))
                fdlim_set(maxfd);
-       fdcon = xmalloc(maxfd * sizeof(con));
-       memset(fdcon, 0, maxfd * sizeof(con));
+       fdcon = xcalloc(maxfd, sizeof(con));
 
-       read_wait_size = howmany(maxfd, NFDBITS) * sizeof(fd_mask);
-       read_wait = xmalloc(read_wait_size);
-       memset(read_wait, 0, read_wait_size);
+       read_wait_nfdset = howmany(maxfd, NFDBITS);
+       read_wait = xcalloc(read_wait_nfdset, sizeof(fd_mask));
 
        if (fopt_count) {
                Linebuf *lb;
This page took 0.038088 seconds and 4 git commands to generate.