diff options
author | Colin Watson <cjwatson@debian.org> | 2009-12-29 21:38:40 +0000 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2009-12-29 21:38:40 +0000 |
commit | 1b816ea846aca3ee89e7995373ace609e9518424 (patch) | |
tree | b41cdc8495cae7fa9c2e0f98a5f2e71656b61f9a /ssh-keyscan.c | |
parent | fa585019a79ebcb4e0202b1c33f87ff1c5c9ce1c (diff) | |
parent | 086ea76990b1e6287c24b6db74adffd4605eb3b0 (diff) |
import openssh-4.6p1-gsskex-20070312.patch
Diffstat (limited to 'ssh-keyscan.c')
-rw-r--r-- | ssh-keyscan.c | 46 |
1 files changed, 30 insertions, 16 deletions
diff --git a/ssh-keyscan.c b/ssh-keyscan.c index 6915102dd..b19864007 100644 --- a/ssh-keyscan.c +++ b/ssh-keyscan.c | |||
@@ -1,3 +1,4 @@ | |||
1 | /* $OpenBSD: ssh-keyscan.c,v 1.74 2006/10/06 02:29:19 djm Exp $ */ | ||
1 | /* | 2 | /* |
2 | * Copyright 1995, 1996 by David Mazieres <dm@lcs.mit.edu>. | 3 | * Copyright 1995, 1996 by David Mazieres <dm@lcs.mit.edu>. |
3 | * | 4 | * |
@@ -7,24 +8,39 @@ | |||
7 | */ | 8 | */ |
8 | 9 | ||
9 | #include "includes.h" | 10 | #include "includes.h" |
10 | RCSID("$OpenBSD: ssh-keyscan.c,v 1.57 2005/10/30 04:01:03 djm Exp $"); | 11 | |
11 | |||
12 | #include "openbsd-compat/sys-queue.h" | 12 | #include "openbsd-compat/sys-queue.h" |
13 | #include <sys/resource.h> | ||
14 | #ifdef HAVE_SYS_TIME_H | ||
15 | # include <sys/time.h> | ||
16 | #endif | ||
17 | |||
18 | #include <netinet/in.h> | ||
19 | #include <arpa/inet.h> | ||
13 | 20 | ||
14 | #include <openssl/bn.h> | 21 | #include <openssl/bn.h> |
15 | 22 | ||
23 | #include <netdb.h> | ||
24 | #include <errno.h> | ||
16 | #include <setjmp.h> | 25 | #include <setjmp.h> |
26 | #include <stdarg.h> | ||
27 | #include <stdio.h> | ||
28 | #include <stdlib.h> | ||
29 | #include <signal.h> | ||
30 | #include <string.h> | ||
31 | #include <unistd.h> | ||
32 | |||
17 | #include "xmalloc.h" | 33 | #include "xmalloc.h" |
18 | #include "ssh.h" | 34 | #include "ssh.h" |
19 | #include "ssh1.h" | 35 | #include "ssh1.h" |
36 | #include "buffer.h" | ||
20 | #include "key.h" | 37 | #include "key.h" |
38 | #include "cipher.h" | ||
21 | #include "kex.h" | 39 | #include "kex.h" |
22 | #include "compat.h" | 40 | #include "compat.h" |
23 | #include "myproposal.h" | 41 | #include "myproposal.h" |
24 | #include "packet.h" | 42 | #include "packet.h" |
25 | #include "dispatch.h" | 43 | #include "dispatch.h" |
26 | #include "buffer.h" | ||
27 | #include "bufaux.h" | ||
28 | #include "log.h" | 44 | #include "log.h" |
29 | #include "atomicio.h" | 45 | #include "atomicio.h" |
30 | #include "misc.h" | 46 | #include "misc.h" |
@@ -54,7 +70,7 @@ int maxfd; | |||
54 | 70 | ||
55 | extern char *__progname; | 71 | extern char *__progname; |
56 | fd_set *read_wait; | 72 | fd_set *read_wait; |
57 | size_t read_wait_size; | 73 | size_t read_wait_nfdset; |
58 | int ncon; | 74 | int ncon; |
59 | int nonfatal_fatal = 0; | 75 | int nonfatal_fatal = 0; |
60 | jmp_buf kexjmp; | 76 | jmp_buf kexjmp; |
@@ -128,7 +144,7 @@ Linebuf_alloc(const char *filename, void (*errfun) (const char *,...)) | |||
128 | lb->stream = stdin; | 144 | lb->stream = stdin; |
129 | } | 145 | } |
130 | 146 | ||
131 | if (!(lb->buf = malloc(lb->size = LINEBUF_SIZE))) { | 147 | if (!(lb->buf = malloc((lb->size = LINEBUF_SIZE)))) { |
132 | if (errfun) | 148 | if (errfun) |
133 | (*errfun) ("linebuf (%s): malloc failed\n", lb->filename); | 149 | (*errfun) ("linebuf (%s): malloc failed\n", lb->filename); |
134 | xfree(lb); | 150 | xfree(lb); |
@@ -350,6 +366,7 @@ keygrab_ssh2(con *c) | |||
350 | c->c_kex->kex[KEX_DH_GRP1_SHA1] = kexdh_client; | 366 | c->c_kex->kex[KEX_DH_GRP1_SHA1] = kexdh_client; |
351 | c->c_kex->kex[KEX_DH_GRP14_SHA1] = kexdh_client; | 367 | c->c_kex->kex[KEX_DH_GRP14_SHA1] = kexdh_client; |
352 | c->c_kex->kex[KEX_DH_GEX_SHA1] = kexgex_client; | 368 | c->c_kex->kex[KEX_DH_GEX_SHA1] = kexgex_client; |
369 | c->c_kex->kex[KEX_DH_GEX_SHA256] = kexgex_client; | ||
353 | c->c_kex->verify_host_key = hostjump; | 370 | c->c_kex->verify_host_key = hostjump; |
354 | 371 | ||
355 | if (!(j = setjmp(kexjmp))) { | 372 | if (!(j = setjmp(kexjmp))) { |
@@ -602,7 +619,6 @@ conread(int s) | |||
602 | keyprint(c, keygrab_ssh1(c)); | 619 | keyprint(c, keygrab_ssh1(c)); |
603 | confree(s); | 620 | confree(s); |
604 | return; | 621 | return; |
605 | break; | ||
606 | default: | 622 | default: |
607 | fatal("conread: invalid status %d", c->c_status); | 623 | fatal("conread: invalid status %d", c->c_status); |
608 | break; | 624 | break; |
@@ -634,10 +650,10 @@ conloop(void) | |||
634 | } else | 650 | } else |
635 | seltime.tv_sec = seltime.tv_usec = 0; | 651 | seltime.tv_sec = seltime.tv_usec = 0; |
636 | 652 | ||
637 | r = xmalloc(read_wait_size); | 653 | r = xcalloc(read_wait_nfdset, sizeof(fd_mask)); |
638 | memcpy(r, read_wait, read_wait_size); | 654 | e = xcalloc(read_wait_nfdset, sizeof(fd_mask)); |
639 | e = xmalloc(read_wait_size); | 655 | memcpy(r, read_wait, read_wait_nfdset * sizeof(fd_mask)); |
640 | memcpy(e, read_wait, read_wait_size); | 656 | memcpy(e, read_wait, read_wait_nfdset * sizeof(fd_mask)); |
641 | 657 | ||
642 | while (select(maxfd, r, NULL, e, &seltime) == -1 && | 658 | while (select(maxfd, r, NULL, e, &seltime) == -1 && |
643 | (errno == EAGAIN || errno == EINTR)) | 659 | (errno == EAGAIN || errno == EINTR)) |
@@ -804,12 +820,10 @@ main(int argc, char **argv) | |||
804 | fatal("%s: not enough file descriptors", __progname); | 820 | fatal("%s: not enough file descriptors", __progname); |
805 | if (maxfd > fdlim_get(0)) | 821 | if (maxfd > fdlim_get(0)) |
806 | fdlim_set(maxfd); | 822 | fdlim_set(maxfd); |
807 | fdcon = xmalloc(maxfd * sizeof(con)); | 823 | fdcon = xcalloc(maxfd, sizeof(con)); |
808 | memset(fdcon, 0, maxfd * sizeof(con)); | ||
809 | 824 | ||
810 | read_wait_size = howmany(maxfd, NFDBITS) * sizeof(fd_mask); | 825 | read_wait_nfdset = howmany(maxfd, NFDBITS); |
811 | read_wait = xmalloc(read_wait_size); | 826 | read_wait = xcalloc(read_wait_nfdset, sizeof(fd_mask)); |
812 | memset(read_wait, 0, read_wait_size); | ||
813 | 827 | ||
814 | if (fopt_count) { | 828 | if (fopt_count) { |
815 | Linebuf *lb; | 829 | Linebuf *lb; |