=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/ssh-keyscan.c,v retrieving revision 1.59.2.2 retrieving revision 1.60 diff -u -r1.59.2.2 -r1.60 --- src/usr.bin/ssh/ssh-keyscan.c 2006/11/08 00:17:14 1.59.2.2 +++ src/usr.bin/ssh/ssh-keyscan.c 2006/03/07 09:07:40 1.60 @@ -1,4 +1,3 @@ -/* $OpenBSD: ssh-keyscan.c,v 1.59.2.2 2006/11/08 00:17:14 brad Exp $ */ /* * Copyright 1995, 1996 by David Mazieres . * @@ -7,35 +6,28 @@ * OpenBSD project by leaving this copyright notice intact. */ -#include -#include +#include "includes.h" +RCSID("$OpenBSD: ssh-keyscan.c,v 1.60 2006/03/07 09:07:40 djm Exp $"); + #include -#include #include -#include - #include -#include #include -#include -#include -#include -#include -#include -#include +#include + #include "xmalloc.h" #include "ssh.h" #include "ssh1.h" -#include "buffer.h" #include "key.h" -#include "cipher.h" #include "kex.h" #include "compat.h" #include "myproposal.h" #include "packet.h" #include "dispatch.h" +#include "buffer.h" +#include "bufaux.h" #include "log.h" #include "atomicio.h" #include "misc.h" @@ -65,7 +57,7 @@ extern char *__progname; fd_set *read_wait; -size_t read_wait_nfdset; +size_t read_wait_size; int ncon; int nonfatal_fatal = 0; jmp_buf kexjmp; @@ -139,7 +131,7 @@ 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); @@ -604,6 +596,7 @@ keyprint(c, keygrab_ssh1(c)); confree(s); return; + break; default: fatal("conread: invalid status %d", c->c_status); break; @@ -635,10 +628,10 @@ } else seltime.tv_sec = seltime.tv_usec = 0; - 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)); + r = xmalloc(read_wait_size); + memcpy(r, read_wait, read_wait_size); + e = xmalloc(read_wait_size); + memcpy(e, read_wait, read_wait_size); while (select(maxfd, r, NULL, e, &seltime) == -1 && (errno == EAGAIN || errno == EINTR)) @@ -802,10 +795,12 @@ fatal("%s: not enough file descriptors", __progname); if (maxfd > fdlim_get(0)) fdlim_set(maxfd); - fdcon = xcalloc(maxfd, sizeof(con)); + fdcon = xmalloc(maxfd * sizeof(con)); + memset(fdcon, 0, maxfd * sizeof(con)); - read_wait_nfdset = howmany(maxfd, NFDBITS); - read_wait = xcalloc(read_wait_nfdset, sizeof(fd_mask)); + read_wait_size = howmany(maxfd, NFDBITS) * sizeof(fd_mask); + read_wait = xmalloc(read_wait_size); + memset(read_wait, 0, read_wait_size); if (fopt_count) { Linebuf *lb;