From: tobias Date: Mon, 6 May 2024 19:26:17 +0000 (+0000) Subject: remove SSH1 leftovers X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=debf255c65d9bae086ca4e05f225ac7a4ba35211;p=openbsd remove SSH1 leftovers Authored with Space Meyer ok djm --- diff --git a/usr.bin/ssh/ssh-keyscan.c b/usr.bin/ssh/ssh-keyscan.c index 7fb8c9e339c..3dbc64cf14a 100644 --- a/usr.bin/ssh/ssh-keyscan.c +++ b/usr.bin/ssh/ssh-keyscan.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-keyscan.c,v 1.156 2024/04/30 15:40:43 tobias Exp $ */ +/* $OpenBSD: ssh-keyscan.c,v 1.157 2024/05/06 19:26:17 tobias Exp $ */ /* * Copyright 1995, 1996 by David Mazieres . * @@ -96,19 +96,13 @@ typedef struct Connection { u_char c_status; /* State of connection on this file desc. */ #define CS_UNUSED 0 /* File descriptor unused */ #define CS_CON 1 /* Waiting to connect/read greeting */ -#define CS_SIZE 2 /* Waiting to read initial packet size */ -#define CS_KEYS 3 /* Waiting to read public key packet */ int c_fd; /* Quick lookup: c->c_fd == c - fdcon */ - int c_plen; /* Packet length field for ssh packet */ - int c_len; /* Total bytes which must be read. */ - int c_off; /* Length of data read so far. */ int c_keytype; /* Only one of KT_* */ sig_atomic_t c_done; /* SSH2 done */ char *c_namebase; /* Address to free for c_name and c_namelist */ char *c_name; /* Hostname of connection for errors */ char *c_namelist; /* Pointer to other possible addresses */ char *c_output_name; /* Hostname of connection for output */ - char *c_data; /* Data read from this fd */ struct ssh *c_ssh; /* SSH-connection */ struct timespec c_ts; /* Time at which connection gets aborted */ TAILQ_ENTRY(Connection) c_link; /* List of connections in timeout order. */ @@ -397,9 +391,6 @@ conalloc(const char *iname, const char *oname, int keytype) fdcon[s].c_name = name; fdcon[s].c_namelist = namelist; fdcon[s].c_output_name = xstrdup(oname); - fdcon[s].c_data = (char *) &fdcon[s].c_plen; - fdcon[s].c_len = 4; - fdcon[s].c_off = 0; fdcon[s].c_keytype = keytype; monotime_ts(&fdcon[s].c_ts); fdcon[s].c_ts.tv_sec += timeout; @@ -417,8 +408,6 @@ confree(int s) fatal("confree: attempt to free bad fdno %d", s); free(fdcon[s].c_namebase); free(fdcon[s].c_output_name); - if (fdcon[s].c_status == CS_KEYS) - free(fdcon[s].c_data); fdcon[s].c_status = CS_UNUSED; fdcon[s].c_keytype = 0; if (fdcon[s].c_ssh) { @@ -433,15 +422,6 @@ confree(int s) ncon--; } -static void -contouch(int s) -{ - TAILQ_REMOVE(&tq, &fdcon[s], c_link); - monotime_ts(&fdcon[s].c_ts); - fdcon[s].c_ts.tv_sec += timeout; - TAILQ_INSERT_TAIL(&tq, &fdcon[s], c_link); -} - static int conrecycle(int s) { @@ -546,35 +526,11 @@ static void conread(int s) { con *c = &fdcon[s]; - size_t n; - if (c->c_status == CS_CON) { - congreet(s); - return; - } - n = atomicio(read, s, c->c_data + c->c_off, c->c_len - c->c_off); - if (n == 0) { - error("read (%s): %s", c->c_name, strerror(errno)); - confree(s); - return; - } - c->c_off += n; - - if (c->c_off == c->c_len) - switch (c->c_status) { - case CS_SIZE: - c->c_plen = htonl(c->c_plen); - c->c_len = c->c_plen + 8 - (c->c_plen & 7); - c->c_off = 0; - c->c_data = xmalloc(c->c_len); - c->c_status = CS_KEYS; - break; - default: - fatal("conread: invalid status %d", c->c_status); - break; - } + if (c->c_status != CS_CON) + fatal("conread: invalid status %d", c->c_status); - contouch(s); + congreet(s); } static void