summaryrefslogtreecommitdiff
path: root/ssh-keyscan.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2006-03-26 14:19:21 +1100
committerDamien Miller <djm@mindrot.org>2006-03-26 14:19:21 +1100
commit07d86bec5eeaf19fe33dca99c8ebcbe9a77c3938 (patch)
tree098295eee2d7ec7b116b0db3ac4b580713dd5ab0 /ssh-keyscan.c
parent7cd4579eb3c5afd22ae24436fd2611cd3aa0150a (diff)
- djm@cvs.openbsd.org 2006/03/25 00:05:41
[auth-bsdauth.c auth-skey.c auth.c auth2-chall.c channels.c] [clientloop.c deattack.c gss-genr.c kex.c key.c misc.c moduli.c] [monitor.c monitor_wrap.c packet.c scard.c sftp-server.c ssh-agent.c] [ssh-keyscan.c ssh.c sshconnect.c sshconnect2.c sshd.c uuencode.c] [xmalloc.c xmalloc.h] introduce xcalloc() and xasprintf() failure-checked allocations functions and use them throughout openssh xcalloc is particularly important because malloc(nmemb * size) is a dangerous idiom (subject to integer overflow) and it is time for it to die feedback and ok deraadt@
Diffstat (limited to 'ssh-keyscan.c')
-rw-r--r--ssh-keyscan.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/ssh-keyscan.c b/ssh-keyscan.c
index c7296938b..07b679442 100644
--- a/ssh-keyscan.c
+++ b/ssh-keyscan.c
@@ -54,7 +54,7 @@ int maxfd;
54 54
55extern char *__progname; 55extern char *__progname;
56fd_set *read_wait; 56fd_set *read_wait;
57size_t read_wait_size; 57size_t read_wait_nfdset;
58int ncon; 58int ncon;
59int nonfatal_fatal = 0; 59int nonfatal_fatal = 0;
60jmp_buf kexjmp; 60jmp_buf kexjmp;
@@ -634,10 +634,10 @@ conloop(void)
634 } else 634 } else
635 seltime.tv_sec = seltime.tv_usec = 0; 635 seltime.tv_sec = seltime.tv_usec = 0;
636 636
637 r = xmalloc(read_wait_size); 637 r = xcalloc(read_wait_nfdset, sizeof(fd_mask));
638 memcpy(r, read_wait, read_wait_size); 638 e = xcalloc(read_wait_nfdset, sizeof(fd_mask));
639 e = xmalloc(read_wait_size); 639 memcpy(r, read_wait, read_wait_nfdset * sizeof(fd_mask));
640 memcpy(e, read_wait, read_wait_size); 640 memcpy(e, read_wait, read_wait_nfdset * sizeof(fd_mask));
641 641
642 while (select(maxfd, r, NULL, e, &seltime) == -1 && 642 while (select(maxfd, r, NULL, e, &seltime) == -1 &&
643 (errno == EAGAIN || errno == EINTR)) 643 (errno == EAGAIN || errno == EINTR))
@@ -804,12 +804,10 @@ main(int argc, char **argv)
804 fatal("%s: not enough file descriptors", __progname); 804 fatal("%s: not enough file descriptors", __progname);
805 if (maxfd > fdlim_get(0)) 805 if (maxfd > fdlim_get(0))
806 fdlim_set(maxfd); 806 fdlim_set(maxfd);
807 fdcon = xmalloc(maxfd * sizeof(con)); 807 fdcon = xcalloc(maxfd, sizeof(con));
808 memset(fdcon, 0, maxfd * sizeof(con));
809 808
810 read_wait_size = howmany(maxfd, NFDBITS) * sizeof(fd_mask); 809 read_wait_nfdset = howmany(maxfd, NFDBITS);
811 read_wait = xmalloc(read_wait_size); 810 read_wait = xcalloc(read_wait_nfdset, sizeof(fd_mask));
812 memset(read_wait, 0, read_wait_size);
813 811
814 if (fopt_count) { 812 if (fopt_count) {
815 Linebuf *lb; 813 Linebuf *lb;