diff options
author | Colin Watson <cjwatson@debian.org> | 2003-09-01 02:05:26 +0000 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2003-09-01 02:05:26 +0000 |
commit | 6d5a72bc1d98a42ba42f082e50a22e911c1d82d3 (patch) | |
tree | 1bf23174bdb6fc71e2846dda0eca195a418484e7 /ssh-keyscan.c | |
parent | 2ee26b431f98cf1dc0e4fb9809ad1e0c879b8c08 (diff) | |
parent | 58657d96514cd6f16d82add8d6f4adbb36765758 (diff) |
Debian release 3.5p1-1.
Diffstat (limited to 'ssh-keyscan.c')
-rw-r--r-- | ssh-keyscan.c | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/ssh-keyscan.c b/ssh-keyscan.c index 1fd011282..788953705 100644 --- a/ssh-keyscan.c +++ b/ssh-keyscan.c | |||
@@ -7,9 +7,9 @@ | |||
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include "includes.h" | 9 | #include "includes.h" |
10 | RCSID("$OpenBSD: ssh-keyscan.c,v 1.36 2002/06/16 21:30:58 itojun Exp $"); | 10 | RCSID("$OpenBSD: ssh-keyscan.c,v 1.40 2002/07/06 17:47:58 stevesk Exp $"); |
11 | 11 | ||
12 | #include "openbsd-compat/fake-queue.h" | 12 | #include "openbsd-compat/sys-queue.h" |
13 | 13 | ||
14 | #include <openssl/bn.h> | 14 | #include <openssl/bn.h> |
15 | 15 | ||
@@ -116,7 +116,8 @@ Linebuf_alloc(const char *filename, void (*errfun) (const char *,...)) | |||
116 | 116 | ||
117 | if (!(lb = malloc(sizeof(*lb)))) { | 117 | if (!(lb = malloc(sizeof(*lb)))) { |
118 | if (errfun) | 118 | if (errfun) |
119 | (*errfun) ("linebuf (%s): malloc failed\n", lb->filename); | 119 | (*errfun) ("linebuf (%s): malloc failed\n", |
120 | filename ? filename : "(stdin)"); | ||
120 | return (NULL); | 121 | return (NULL); |
121 | } | 122 | } |
122 | if (filename) { | 123 | if (filename) { |
@@ -171,13 +172,14 @@ static char * | |||
171 | Linebuf_getline(Linebuf * lb) | 172 | Linebuf_getline(Linebuf * lb) |
172 | { | 173 | { |
173 | int n = 0; | 174 | int n = 0; |
175 | void *p; | ||
174 | 176 | ||
175 | lb->lineno++; | 177 | lb->lineno++; |
176 | for (;;) { | 178 | for (;;) { |
177 | /* Read a line */ | 179 | /* Read a line */ |
178 | if (!fgets(&lb->buf[n], lb->size - n, lb->stream)) { | 180 | if (!fgets(&lb->buf[n], lb->size - n, lb->stream)) { |
179 | if (ferror(lb->stream) && lb->errfun) | 181 | if (ferror(lb->stream) && lb->errfun) |
180 | (*lb->errfun) ("%s: %s\n", lb->filename, | 182 | (*lb->errfun)("%s: %s\n", lb->filename, |
181 | strerror(errno)); | 183 | strerror(errno)); |
182 | return (NULL); | 184 | return (NULL); |
183 | } | 185 | } |
@@ -190,17 +192,20 @@ Linebuf_getline(Linebuf * lb) | |||
190 | } | 192 | } |
191 | if (n != lb->size - 1) { | 193 | if (n != lb->size - 1) { |
192 | if (lb->errfun) | 194 | if (lb->errfun) |
193 | (*lb->errfun) ("%s: skipping incomplete last line\n", | 195 | (*lb->errfun)("%s: skipping incomplete last line\n", |
194 | lb->filename); | 196 | lb->filename); |
195 | return (NULL); | 197 | return (NULL); |
196 | } | 198 | } |
197 | /* Double the buffer if we need more space */ | 199 | /* Double the buffer if we need more space */ |
198 | if (!(lb->buf = realloc(lb->buf, (lb->size *= 2)))) { | 200 | lb->size *= 2; |
201 | if ((p = realloc(lb->buf, lb->size)) == NULL) { | ||
202 | lb->size /= 2; | ||
199 | if (lb->errfun) | 203 | if (lb->errfun) |
200 | (*lb->errfun) ("linebuf (%s): realloc failed\n", | 204 | (*lb->errfun)("linebuf (%s): realloc failed\n", |
201 | lb->filename); | 205 | lb->filename); |
202 | return (NULL); | 206 | return (NULL); |
203 | } | 207 | } |
208 | lb->buf = p; | ||
204 | } | 209 | } |
205 | } | 210 | } |
206 | 211 | ||
@@ -229,6 +234,7 @@ fdlim_set(int lim) | |||
229 | #if defined(HAVE_SETRLIMIT) && defined(RLIMIT_NOFILE) | 234 | #if defined(HAVE_SETRLIMIT) && defined(RLIMIT_NOFILE) |
230 | struct rlimit rlfd; | 235 | struct rlimit rlfd; |
231 | #endif | 236 | #endif |
237 | |||
232 | if (lim <= 0) | 238 | if (lim <= 0) |
233 | return (-1); | 239 | return (-1); |
234 | #if defined(HAVE_SETRLIMIT) && defined(RLIMIT_NOFILE) | 240 | #if defined(HAVE_SETRLIMIT) && defined(RLIMIT_NOFILE) |
@@ -411,8 +417,8 @@ tcpconnect(char *host) | |||
411 | static int | 417 | static int |
412 | conalloc(char *iname, char *oname, int keytype) | 418 | conalloc(char *iname, char *oname, int keytype) |
413 | { | 419 | { |
414 | int s; | ||
415 | char *namebase, *name, *namelist; | 420 | char *namebase, *name, *namelist; |
421 | int s; | ||
416 | 422 | ||
417 | namebase = namelist = xstrdup(iname); | 423 | namebase = namelist = xstrdup(iname); |
418 | 424 | ||
@@ -476,8 +482,8 @@ contouch(int s) | |||
476 | static int | 482 | static int |
477 | conrecycle(int s) | 483 | conrecycle(int s) |
478 | { | 484 | { |
479 | int ret; | ||
480 | con *c = &fdcon[s]; | 485 | con *c = &fdcon[s]; |
486 | int ret; | ||
481 | 487 | ||
482 | ret = conalloc(c->c_namelist, c->c_output_name, c->c_keytype); | 488 | ret = conalloc(c->c_namelist, c->c_output_name, c->c_keytype); |
483 | confree(s); | 489 | confree(s); |
@@ -487,10 +493,10 @@ conrecycle(int s) | |||
487 | static void | 493 | static void |
488 | congreet(int s) | 494 | congreet(int s) |
489 | { | 495 | { |
496 | int remote_major, remote_minor, n = 0; | ||
490 | char buf[256], *cp; | 497 | char buf[256], *cp; |
491 | char remote_version[sizeof buf]; | 498 | char remote_version[sizeof buf]; |
492 | size_t bufsiz; | 499 | size_t bufsiz; |
493 | int remote_major, remote_minor, n = 0; | ||
494 | con *c = &fdcon[s]; | 500 | con *c = &fdcon[s]; |
495 | 501 | ||
496 | bufsiz = sizeof(buf); | 502 | bufsiz = sizeof(buf); |
@@ -554,8 +560,8 @@ congreet(int s) | |||
554 | static void | 560 | static void |
555 | conread(int s) | 561 | conread(int s) |
556 | { | 562 | { |
557 | int n; | ||
558 | con *c = &fdcon[s]; | 563 | con *c = &fdcon[s]; |
564 | int n; | ||
559 | 565 | ||
560 | if (c->c_status == CS_CON) { | 566 | if (c->c_status == CS_CON) { |
561 | congreet(s); | 567 | congreet(s); |
@@ -594,10 +600,10 @@ conread(int s) | |||
594 | static void | 600 | static void |
595 | conloop(void) | 601 | conloop(void) |
596 | { | 602 | { |
597 | fd_set *r, *e; | ||
598 | struct timeval seltime, now; | 603 | struct timeval seltime, now; |
599 | int i; | 604 | fd_set *r, *e; |
600 | con *c; | 605 | con *c; |
606 | int i; | ||
601 | 607 | ||
602 | gettimeofday(&now, NULL); | 608 | gettimeofday(&now, NULL); |
603 | c = TAILQ_FIRST(&tq); | 609 | c = TAILQ_FIRST(&tq); |
@@ -664,6 +670,7 @@ void | |||
664 | fatal(const char *fmt,...) | 670 | fatal(const char *fmt,...) |
665 | { | 671 | { |
666 | va_list args; | 672 | va_list args; |
673 | |||
667 | va_start(args, fmt); | 674 | va_start(args, fmt); |
668 | do_log(SYSLOG_LEVEL_FATAL, fmt, args); | 675 | do_log(SYSLOG_LEVEL_FATAL, fmt, args); |
669 | va_end(args); | 676 | va_end(args); |
@@ -676,16 +683,9 @@ fatal(const char *fmt,...) | |||
676 | static void | 683 | static void |
677 | usage(void) | 684 | usage(void) |
678 | { | 685 | { |
679 | fprintf(stderr, "Usage: %s [options] host ...\n", | 686 | fprintf(stderr, "usage: %s [-v46] [-p port] [-T timeout] [-f file]\n" |
687 | "\t\t [host | addrlist namelist] [...]\n", | ||
680 | __progname); | 688 | __progname); |
681 | fprintf(stderr, "Options:\n"); | ||
682 | fprintf(stderr, " -f file Read hosts or addresses from file.\n"); | ||
683 | fprintf(stderr, " -p port Connect to the specified port.\n"); | ||
684 | fprintf(stderr, " -t keytype Specify the host key type.\n"); | ||
685 | fprintf(stderr, " -T timeout Set connection timeout.\n"); | ||
686 | fprintf(stderr, " -v Verbose; display verbose debugging messages.\n"); | ||
687 | fprintf(stderr, " -4 Use IPv4 only.\n"); | ||
688 | fprintf(stderr, " -6 Use IPv6 only.\n"); | ||
689 | exit(1); | 689 | exit(1); |
690 | } | 690 | } |
691 | 691 | ||
@@ -717,9 +717,11 @@ main(int argc, char **argv) | |||
717 | } | 717 | } |
718 | break; | 718 | break; |
719 | case 'T': | 719 | case 'T': |
720 | timeout = atoi(optarg); | 720 | timeout = convtime(optarg); |
721 | if (timeout <= 0) | 721 | if (timeout == -1 || timeout == 0) { |
722 | fprintf(stderr, "Bad timeout '%s'\n", optarg); | ||
722 | usage(); | 723 | usage(); |
724 | } | ||
723 | break; | 725 | break; |
724 | case 'v': | 726 | case 'v': |
725 | if (!debug_flag) { | 727 | if (!debug_flag) { |