summaryrefslogtreecommitdiffstats
path: root/crypto/openssh/ssh-keyscan.c
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2002-10-29 10:16:02 +0000
committerdes <des@FreeBSD.org>2002-10-29 10:16:02 +0000
commit279b0fa809e30e3a007bbc4b2adb1ccbd4d4a87a (patch)
tree404fa392fc6f2560e3c459fa20228c7031d0289d /crypto/openssh/ssh-keyscan.c
parentce26c10eda4d687d476e9bbac51ccd26564af8da (diff)
downloadFreeBSD-src-279b0fa809e30e3a007bbc4b2adb1ccbd4d4a87a.zip
FreeBSD-src-279b0fa809e30e3a007bbc4b2adb1ccbd4d4a87a.tar.gz
Resolve conflicts.
Diffstat (limited to 'crypto/openssh/ssh-keyscan.c')
-rw-r--r--crypto/openssh/ssh-keyscan.c51
1 files changed, 27 insertions, 24 deletions
diff --git a/crypto/openssh/ssh-keyscan.c b/crypto/openssh/ssh-keyscan.c
index 333a38e..fb5ca7f 100644
--- a/crypto/openssh/ssh-keyscan.c
+++ b/crypto/openssh/ssh-keyscan.c
@@ -7,9 +7,10 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: ssh-keyscan.c,v 1.36 2002/06/16 21:30:58 itojun Exp $");
+RCSID("$OpenBSD: ssh-keyscan.c,v 1.40 2002/07/06 17:47:58 stevesk Exp $");
+RCSID("$FreeBSD$");
-#include "openbsd-compat/fake-queue.h"
+#include "openbsd-compat/sys-queue.h"
#include <openssl/bn.h>
@@ -116,7 +117,8 @@ Linebuf_alloc(const char *filename, void (*errfun) (const char *,...))
if (!(lb = malloc(sizeof(*lb)))) {
if (errfun)
- (*errfun) ("linebuf (%s): malloc failed\n", lb->filename);
+ (*errfun) ("linebuf (%s): malloc failed\n",
+ filename ? filename : "(stdin)");
return (NULL);
}
if (filename) {
@@ -171,13 +173,14 @@ static char *
Linebuf_getline(Linebuf * lb)
{
int n = 0;
+ void *p;
lb->lineno++;
for (;;) {
/* Read a line */
if (!fgets(&lb->buf[n], lb->size - n, lb->stream)) {
if (ferror(lb->stream) && lb->errfun)
- (*lb->errfun) ("%s: %s\n", lb->filename,
+ (*lb->errfun)("%s: %s\n", lb->filename,
strerror(errno));
return (NULL);
}
@@ -190,17 +193,20 @@ Linebuf_getline(Linebuf * lb)
}
if (n != lb->size - 1) {
if (lb->errfun)
- (*lb->errfun) ("%s: skipping incomplete last line\n",
+ (*lb->errfun)("%s: skipping incomplete last line\n",
lb->filename);
return (NULL);
}
/* Double the buffer if we need more space */
- if (!(lb->buf = realloc(lb->buf, (lb->size *= 2)))) {
+ lb->size *= 2;
+ if ((p = realloc(lb->buf, lb->size)) == NULL) {
+ lb->size /= 2;
if (lb->errfun)
- (*lb->errfun) ("linebuf (%s): realloc failed\n",
+ (*lb->errfun)("linebuf (%s): realloc failed\n",
lb->filename);
return (NULL);
}
+ lb->buf = p;
}
}
@@ -229,6 +235,7 @@ fdlim_set(int lim)
#if defined(HAVE_SETRLIMIT) && defined(RLIMIT_NOFILE)
struct rlimit rlfd;
#endif
+
if (lim <= 0)
return (-1);
#if defined(HAVE_SETRLIMIT) && defined(RLIMIT_NOFILE)
@@ -411,8 +418,8 @@ tcpconnect(char *host)
static int
conalloc(char *iname, char *oname, int keytype)
{
- int s;
char *namebase, *name, *namelist;
+ int s;
namebase = namelist = xstrdup(iname);
@@ -476,8 +483,8 @@ contouch(int s)
static int
conrecycle(int s)
{
- int ret;
con *c = &fdcon[s];
+ int ret;
ret = conalloc(c->c_namelist, c->c_output_name, c->c_keytype);
confree(s);
@@ -487,10 +494,10 @@ conrecycle(int s)
static void
congreet(int s)
{
+ int remote_major, remote_minor, n = 0;
char buf[256], *cp;
char remote_version[sizeof buf];
size_t bufsiz;
- int remote_major, remote_minor, n = 0;
con *c = &fdcon[s];
bufsiz = sizeof(buf);
@@ -554,8 +561,8 @@ congreet(int s)
static void
conread(int s)
{
- int n;
con *c = &fdcon[s];
+ int n;
if (c->c_status == CS_CON) {
congreet(s);
@@ -594,10 +601,10 @@ conread(int s)
static void
conloop(void)
{
- fd_set *r, *e;
struct timeval seltime, now;
- int i;
+ fd_set *r, *e;
con *c;
+ int i;
gettimeofday(&now, NULL);
c = TAILQ_FIRST(&tq);
@@ -664,6 +671,7 @@ void
fatal(const char *fmt,...)
{
va_list args;
+
va_start(args, fmt);
do_log(SYSLOG_LEVEL_FATAL, fmt, args);
va_end(args);
@@ -676,16 +684,9 @@ fatal(const char *fmt,...)
static void
usage(void)
{
- fprintf(stderr, "Usage: %s [options] host ...\n",
+ fprintf(stderr, "usage: %s [-v46] [-p port] [-T timeout] [-f file]\n"
+ "\t\t [host | addrlist namelist] [...]\n",
__progname);
- fprintf(stderr, "Options:\n");
- fprintf(stderr, " -f file Read hosts or addresses from file.\n");
- fprintf(stderr, " -p port Connect to the specified port.\n");
- fprintf(stderr, " -t keytype Specify the host key type.\n");
- fprintf(stderr, " -T timeout Set connection timeout.\n");
- fprintf(stderr, " -v Verbose; display verbose debugging messages.\n");
- fprintf(stderr, " -4 Use IPv4 only.\n");
- fprintf(stderr, " -6 Use IPv6 only.\n");
exit(1);
}
@@ -717,9 +718,11 @@ main(int argc, char **argv)
}
break;
case 'T':
- timeout = atoi(optarg);
- if (timeout <= 0)
+ timeout = convtime(optarg);
+ if (timeout == -1 || timeout == 0) {
+ fprintf(stderr, "Bad timeout '%s'\n", optarg);
usage();
+ }
break;
case 'v':
if (!debug_flag) {
OpenPOWER on IntegriCloud