summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2001-12-21 15:00:19 +1100
committerDamien Miller <djm@mindrot.org>2001-12-21 15:00:19 +1100
commit278f907a2d6d00d6f52a11bf9577648aadbf0994 (patch)
tree50f885a7fd73b813754e3b675e810dc01ba78b78
parente737856350287104a12f5a97c81fad1f7bcd7096 (diff)
- djm@cvs.openbsd.org 2001/12/20 22:50:24
[auth2.c auth2-chall.c channels.c channels.h clientloop.c dispatch.c] [dispatch.h kex.c kex.h packet.c packet.h serverloop.c ssh.c] [sshconnect2.c] Conformance fix: we should send failing packet sequence number when responding with a SSH_MSG_UNIMPLEMENTED message. Spotted by yakk@yakk.dot.net; ok markus@
-rw-r--r--ChangeLog9
-rw-r--r--auth2-chall.c6
-rw-r--r--auth2.c16
-rw-r--r--channels.c30
-rw-r--r--channels.h30
-rw-r--r--clientloop.c12
-rw-r--r--dispatch.c14
-rw-r--r--dispatch.h6
-rw-r--r--kex.c6
-rw-r--r--kex.h4
-rw-r--r--packet.c28
-rw-r--r--packet.h4
-rw-r--r--serverloop.c14
-rw-r--r--ssh.c4
-rw-r--r--sshconnect2.c26
15 files changed, 117 insertions, 92 deletions
diff --git a/ChangeLog b/ChangeLog
index 2979b95f1..7ce2187a0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -51,6 +51,13 @@
51 [channels.c channels.h session.c] 51 [channels.c channels.h session.c]
52 setup x11 listen socket for just one connect if the client requests so. 52 setup x11 listen socket for just one connect if the client requests so.
53 (v2 only, but the openssh client does not support this feature). 53 (v2 only, but the openssh client does not support this feature).
54 - djm@cvs.openbsd.org 2001/12/20 22:50:24
55 [auth2.c auth2-chall.c channels.c channels.h clientloop.c dispatch.c]
56 [dispatch.h kex.c kex.h packet.c packet.h serverloop.c ssh.c]
57 [sshconnect2.c]
58 Conformance fix: we should send failing packet sequence number when
59 responding with a SSH_MSG_UNIMPLEMENTED message. Spotted by
60 yakk@yakk.dot.net; ok markus@
54 61
5520011219 6220011219
56 - (stevesk) OpenBSD CVS sync X11 localhost display 63 - (stevesk) OpenBSD CVS sync X11 localhost display
@@ -7079,4 +7086,4 @@
7079 - Wrote replacements for strlcpy and mkdtemp 7086 - Wrote replacements for strlcpy and mkdtemp
7080 - Released 1.0pre1 7087 - Released 1.0pre1
7081 7088
7082$Id: ChangeLog,v 1.1704 2001/12/21 03:58:35 djm Exp $ 7089$Id: ChangeLog,v 1.1705 2001/12/21 04:00:19 djm Exp $
diff --git a/auth2-chall.c b/auth2-chall.c
index 8ad1efcd6..8679f632f 100644
--- a/auth2-chall.c
+++ b/auth2-chall.c
@@ -23,7 +23,7 @@
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25#include "includes.h" 25#include "includes.h"
26RCSID("$OpenBSD: auth2-chall.c,v 1.10 2001/12/19 07:18:56 deraadt Exp $"); 26RCSID("$OpenBSD: auth2-chall.c,v 1.11 2001/12/20 22:50:24 djm Exp $");
27 27
28#include "ssh2.h" 28#include "ssh2.h"
29#include "auth.h" 29#include "auth.h"
@@ -35,7 +35,7 @@ RCSID("$OpenBSD: auth2-chall.c,v 1.10 2001/12/19 07:18:56 deraadt Exp $");
35 35
36static int auth2_challenge_start(Authctxt *); 36static int auth2_challenge_start(Authctxt *);
37static int send_userauth_info_request(Authctxt *); 37static int send_userauth_info_request(Authctxt *);
38static void input_userauth_info_response(int, int, void *); 38static void input_userauth_info_response(int, int, u_int32_t, void *);
39 39
40#ifdef BSD_AUTH 40#ifdef BSD_AUTH
41extern KbdintDevice bsdauth_device; 41extern KbdintDevice bsdauth_device;
@@ -234,7 +234,7 @@ send_userauth_info_request(Authctxt *authctxt)
234} 234}
235 235
236static void 236static void
237input_userauth_info_response(int type, int plen, void *ctxt) 237input_userauth_info_response(int type, int plen, u_int32_t seq, void *ctxt)
238{ 238{
239 Authctxt *authctxt = ctxt; 239 Authctxt *authctxt = ctxt;
240 KbdintAuthctxt *kbdintctxt; 240 KbdintAuthctxt *kbdintctxt;
diff --git a/auth2.c b/auth2.c
index 929e87baa..b564a8f3c 100644
--- a/auth2.c
+++ b/auth2.c
@@ -23,7 +23,7 @@
23 */ 23 */
24 24
25#include "includes.h" 25#include "includes.h"
26RCSID("$OpenBSD: auth2.c,v 1.77 2001/12/19 07:18:56 deraadt Exp $"); 26RCSID("$OpenBSD: auth2.c,v 1.78 2001/12/20 22:50:24 djm Exp $");
27 27
28#include <openssl/evp.h> 28#include <openssl/evp.h>
29 29
@@ -69,9 +69,9 @@ struct Authmethod {
69 69
70/* protocol */ 70/* protocol */
71 71
72static void input_service_request(int, int, void *); 72static void input_service_request(int, int, u_int32_t, void *);
73static void input_userauth_request(int, int, void *); 73static void input_userauth_request(int, int, u_int32_t, void *);
74static void protocol_error(int, int, void *); 74static void protocol_error(int, int, u_int32_t, void *);
75 75
76/* helper */ 76/* helper */
77static Authmethod *authmethod_lookup(const char *); 77static Authmethod *authmethod_lookup(const char *);
@@ -130,17 +130,17 @@ do_authentication2(void)
130} 130}
131 131
132static void 132static void
133protocol_error(int type, int plen, void *ctxt) 133protocol_error(int type, int plen, u_int32_t seq, void *ctxt)
134{ 134{
135 log("auth: protocol error: type %d plen %d", type, plen); 135 log("auth: protocol error: type %d plen %d", type, plen);
136 packet_start(SSH2_MSG_UNIMPLEMENTED); 136 packet_start(SSH2_MSG_UNIMPLEMENTED);
137 packet_put_int(0); 137 packet_put_int(seq);
138 packet_send(); 138 packet_send();
139 packet_write_wait(); 139 packet_write_wait();
140} 140}
141 141
142static void 142static void
143input_service_request(int type, int plen, void *ctxt) 143input_service_request(int type, int plen, u_int32_t seq, void *ctxt)
144{ 144{
145 Authctxt *authctxt = ctxt; 145 Authctxt *authctxt = ctxt;
146 u_int len; 146 u_int len;
@@ -173,7 +173,7 @@ input_service_request(int type, int plen, void *ctxt)
173} 173}
174 174
175static void 175static void
176input_userauth_request(int type, int plen, void *ctxt) 176input_userauth_request(int type, int plen, u_int32_t seq, void *ctxt)
177{ 177{
178 Authctxt *authctxt = ctxt; 178 Authctxt *authctxt = ctxt;
179 Authmethod *m = NULL; 179 Authmethod *m = NULL;
diff --git a/channels.c b/channels.c
index 340b10646..cc2613a88 100644
--- a/channels.c
+++ b/channels.c
@@ -39,7 +39,7 @@
39 */ 39 */
40 40
41#include "includes.h" 41#include "includes.h"
42RCSID("$OpenBSD: channels.c,v 1.149 2001/12/20 16:37:29 markus Exp $"); 42RCSID("$OpenBSD: channels.c,v 1.150 2001/12/20 22:50:24 djm Exp $");
43 43
44#include "ssh.h" 44#include "ssh.h"
45#include "ssh1.h" 45#include "ssh1.h"
@@ -1710,7 +1710,7 @@ channel_output_poll(void)
1710/* -- protocol input */ 1710/* -- protocol input */
1711 1711
1712void 1712void
1713channel_input_data(int type, int plen, void *ctxt) 1713channel_input_data(int type, int plen, u_int32_t seq, void *ctxt)
1714{ 1714{
1715 int id; 1715 int id;
1716 char *data; 1716 char *data;
@@ -1756,7 +1756,7 @@ channel_input_data(int type, int plen, void *ctxt)
1756} 1756}
1757 1757
1758void 1758void
1759channel_input_extended_data(int type, int plen, void *ctxt) 1759channel_input_extended_data(int type, int plen, u_int32_t seq, void *ctxt)
1760{ 1760{
1761 int id; 1761 int id;
1762 int tcode; 1762 int tcode;
@@ -1796,7 +1796,7 @@ channel_input_extended_data(int type, int plen, void *ctxt)
1796} 1796}
1797 1797
1798void 1798void
1799channel_input_ieof(int type, int plen, void *ctxt) 1799channel_input_ieof(int type, int plen, u_int32_t seq, void *ctxt)
1800{ 1800{
1801 int id; 1801 int id;
1802 Channel *c; 1802 Channel *c;
@@ -1818,7 +1818,7 @@ channel_input_ieof(int type, int plen, void *ctxt)
1818} 1818}
1819 1819
1820void 1820void
1821channel_input_close(int type, int plen, void *ctxt) 1821channel_input_close(int type, int plen, u_int32_t seq, void *ctxt)
1822{ 1822{
1823 int id; 1823 int id;
1824 Channel *c; 1824 Channel *c;
@@ -1857,7 +1857,7 @@ channel_input_close(int type, int plen, void *ctxt)
1857 1857
1858/* proto version 1.5 overloads CLOSE_CONFIRMATION with OCLOSE */ 1858/* proto version 1.5 overloads CLOSE_CONFIRMATION with OCLOSE */
1859void 1859void
1860channel_input_oclose(int type, int plen, void *ctxt) 1860channel_input_oclose(int type, int plen, u_int32_t seq, void *ctxt)
1861{ 1861{
1862 int id = packet_get_int(); 1862 int id = packet_get_int();
1863 Channel *c = channel_lookup(id); 1863 Channel *c = channel_lookup(id);
@@ -1868,7 +1868,7 @@ channel_input_oclose(int type, int plen, void *ctxt)
1868} 1868}
1869 1869
1870void 1870void
1871channel_input_close_confirmation(int type, int plen, void *ctxt) 1871channel_input_close_confirmation(int type, int plen, u_int32_t seq, void *ctxt)
1872{ 1872{
1873 int id = packet_get_int(); 1873 int id = packet_get_int();
1874 Channel *c = channel_lookup(id); 1874 Channel *c = channel_lookup(id);
@@ -1884,7 +1884,7 @@ channel_input_close_confirmation(int type, int plen, void *ctxt)
1884} 1884}
1885 1885
1886void 1886void
1887channel_input_open_confirmation(int type, int plen, void *ctxt) 1887channel_input_open_confirmation(int type, int plen, u_int32_t seq, void *ctxt)
1888{ 1888{
1889 int id, remote_id; 1889 int id, remote_id;
1890 Channel *c; 1890 Channel *c;
@@ -1934,7 +1934,7 @@ reason2txt(int reason)
1934} 1934}
1935 1935
1936void 1936void
1937channel_input_open_failure(int type, int plen, void *ctxt) 1937channel_input_open_failure(int type, int plen, u_int32_t seq, void *ctxt)
1938{ 1938{
1939 int id, reason; 1939 int id, reason;
1940 char *msg = NULL, *lang = NULL; 1940 char *msg = NULL, *lang = NULL;
@@ -1968,7 +1968,7 @@ channel_input_open_failure(int type, int plen, void *ctxt)
1968} 1968}
1969 1969
1970void 1970void
1971channel_input_channel_request(int type, int plen, void *ctxt) 1971channel_input_channel_request(int type, int plen, u_int32_t seq, void *ctxt)
1972{ 1972{
1973 int id; 1973 int id;
1974 Channel *c; 1974 Channel *c;
@@ -1993,7 +1993,7 @@ channel_input_channel_request(int type, int plen, void *ctxt)
1993} 1993}
1994 1994
1995void 1995void
1996channel_input_window_adjust(int type, int plen, void *ctxt) 1996channel_input_window_adjust(int type, int plen, u_int32_t seq, void *ctxt)
1997{ 1997{
1998 Channel *c; 1998 Channel *c;
1999 int id, adjust; 1999 int id, adjust;
@@ -2017,7 +2017,7 @@ channel_input_window_adjust(int type, int plen, void *ctxt)
2017} 2017}
2018 2018
2019void 2019void
2020channel_input_port_open(int type, int plen, void *ctxt) 2020channel_input_port_open(int type, int plen, u_int32_t seq, void *ctxt)
2021{ 2021{
2022 Channel *c = NULL; 2022 Channel *c = NULL;
2023 u_short host_port; 2023 u_short host_port;
@@ -2624,7 +2624,7 @@ x11_connect_display(void)
2624 */ 2624 */
2625 2625
2626void 2626void
2627x11_input_open(int type, int plen, void *ctxt) 2627x11_input_open(int type, int plen, u_int32_t seq, void *ctxt)
2628{ 2628{
2629 Channel *c = NULL; 2629 Channel *c = NULL;
2630 int remote_id, sock = 0; 2630 int remote_id, sock = 0;
@@ -2671,7 +2671,7 @@ x11_input_open(int type, int plen, void *ctxt)
2671 2671
2672/* dummy protocol handler that denies SSH-1 requests (agent/x11) */ 2672/* dummy protocol handler that denies SSH-1 requests (agent/x11) */
2673void 2673void
2674deny_input_open(int type, int plen, void *ctxt) 2674deny_input_open(int type, int plen, u_int32_t seq, void *ctxt)
2675{ 2675{
2676 int rchan = packet_get_int(); 2676 int rchan = packet_get_int();
2677 switch (type) { 2677 switch (type) {
@@ -2882,7 +2882,7 @@ auth_input_request_forwarding(struct passwd * pw)
2882/* This is called to process an SSH_SMSG_AGENT_OPEN message. */ 2882/* This is called to process an SSH_SMSG_AGENT_OPEN message. */
2883 2883
2884void 2884void
2885auth_input_open_request(int type, int plen, void *ctxt) 2885auth_input_open_request(int type, int plen, u_int32_t seq, void *ctxt)
2886{ 2886{
2887 Channel *c = NULL; 2887 Channel *c = NULL;
2888 int remote_id, sock; 2888 int remote_id, sock;
diff --git a/channels.h b/channels.h
index e994aaeb6..c54b23e67 100644
--- a/channels.h
+++ b/channels.h
@@ -32,7 +32,7 @@
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */ 34 */
35/* RCSID("$OpenBSD: channels.h,v 1.54 2001/12/20 16:37:29 markus Exp $"); */ 35/* RCSID("$OpenBSD: channels.h,v 1.55 2001/12/20 22:50:24 djm Exp $"); */
36 36
37#ifndef CHANNEL_H 37#ifndef CHANNEL_H
38#define CHANNEL_H 38#define CHANNEL_H
@@ -157,17 +157,17 @@ int channel_close_fd(int *);
157 157
158/* protocol handler */ 158/* protocol handler */
159 159
160void channel_input_channel_request(int, int, void *); 160void channel_input_channel_request(int, int, u_int32_t, void *);
161void channel_input_close(int, int, void *); 161void channel_input_close(int, int, u_int32_t, void *);
162void channel_input_close_confirmation(int, int, void *); 162void channel_input_close_confirmation(int, int, u_int32_t, void *);
163void channel_input_data(int, int, void *); 163void channel_input_data(int, int, u_int32_t, void *);
164void channel_input_extended_data(int, int, void *); 164void channel_input_extended_data(int, int, u_int32_t, void *);
165void channel_input_ieof(int, int, void *); 165void channel_input_ieof(int, int, u_int32_t, void *);
166void channel_input_oclose(int, int, void *); 166void channel_input_oclose(int, int, u_int32_t, void *);
167void channel_input_open_confirmation(int, int, void *); 167void channel_input_open_confirmation(int, int, u_int32_t, void *);
168void channel_input_open_failure(int, int, void *); 168void channel_input_open_failure(int, int, u_int32_t, void *);
169void channel_input_port_open(int, int, void *); 169void channel_input_port_open(int, int, u_int32_t, void *);
170void channel_input_window_adjust(int, int, void *); 170void channel_input_window_adjust(int, int, u_int32_t, void *);
171 171
172/* file descriptor handling (read/write) */ 172/* file descriptor handling (read/write) */
173 173
@@ -199,9 +199,9 @@ channel_request_forwarding(const char *, u_short, const char *, u_short, int,
199 199
200int x11_connect_display(void); 200int x11_connect_display(void);
201int x11_create_display_inet(int, int, int); 201int x11_create_display_inet(int, int, int);
202void x11_input_open(int, int, void *); 202void x11_input_open(int, int, u_int32_t, void *);
203void x11_request_forwarding_with_spoofing(int, const char *, const char *); 203void x11_request_forwarding_with_spoofing(int, const char *, const char *);
204void deny_input_open(int, int, void *); 204void deny_input_open(int, int, u_int32_t, void *);
205 205
206/* agent forwarding */ 206/* agent forwarding */
207 207
@@ -209,7 +209,7 @@ void auth_request_forwarding(void);
209char *auth_get_socket_name(void); 209char *auth_get_socket_name(void);
210void auth_sock_cleanup_proc(void *); 210void auth_sock_cleanup_proc(void *);
211int auth_input_request_forwarding(struct passwd *); 211int auth_input_request_forwarding(struct passwd *);
212void auth_input_open_request(int, int, void *); 212void auth_input_open_request(int, int, u_int32_t, void *);
213 213
214/* channel close */ 214/* channel close */
215 215
diff --git a/clientloop.c b/clientloop.c
index 84484604d..9e4f247c6 100644
--- a/clientloop.c
+++ b/clientloop.c
@@ -59,7 +59,7 @@
59 */ 59 */
60 60
61#include "includes.h" 61#include "includes.h"
62RCSID("$OpenBSD: clientloop.c,v 1.90 2001/12/19 07:18:56 deraadt Exp $"); 62RCSID("$OpenBSD: clientloop.c,v 1.91 2001/12/20 22:50:24 djm Exp $");
63 63
64#include "ssh.h" 64#include "ssh.h"
65#include "ssh1.h" 65#include "ssh1.h"
@@ -1008,7 +1008,7 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id)
1008/*********/ 1008/*********/
1009 1009
1010static void 1010static void
1011client_input_stdout_data(int type, int plen, void *ctxt) 1011client_input_stdout_data(int type, int plen, u_int32_t seq, void *ctxt)
1012{ 1012{
1013 u_int data_len; 1013 u_int data_len;
1014 char *data = packet_get_string(&data_len); 1014 char *data = packet_get_string(&data_len);
@@ -1018,7 +1018,7 @@ client_input_stdout_data(int type, int plen, void *ctxt)
1018 xfree(data); 1018 xfree(data);
1019} 1019}
1020static void 1020static void
1021client_input_stderr_data(int type, int plen, void *ctxt) 1021client_input_stderr_data(int type, int plen, u_int32_t seq, void *ctxt)
1022{ 1022{
1023 u_int data_len; 1023 u_int data_len;
1024 char *data = packet_get_string(&data_len); 1024 char *data = packet_get_string(&data_len);
@@ -1028,7 +1028,7 @@ client_input_stderr_data(int type, int plen, void *ctxt)
1028 xfree(data); 1028 xfree(data);
1029} 1029}
1030static void 1030static void
1031client_input_exit_status(int type, int plen, void *ctxt) 1031client_input_exit_status(int type, int plen, u_int32_t seq, void *ctxt)
1032{ 1032{
1033 packet_integrity_check(plen, 4, type); 1033 packet_integrity_check(plen, 4, type);
1034 exit_status = packet_get_int(); 1034 exit_status = packet_get_int();
@@ -1149,7 +1149,7 @@ client_request_agent(const char *request_type, int rchan)
1149 1149
1150/* XXXX move to generic input handler */ 1150/* XXXX move to generic input handler */
1151static void 1151static void
1152client_input_channel_open(int type, int plen, void *ctxt) 1152client_input_channel_open(int type, int plen, u_int32_t seq, void *ctxt)
1153{ 1153{
1154 Channel *c = NULL; 1154 Channel *c = NULL;
1155 char *ctype; 1155 char *ctype;
@@ -1201,7 +1201,7 @@ client_input_channel_open(int type, int plen, void *ctxt)
1201 xfree(ctype); 1201 xfree(ctype);
1202} 1202}
1203static void 1203static void
1204client_input_channel_req(int type, int plen, void *ctxt) 1204client_input_channel_req(int type, int plen, u_int32_t seq, void *ctxt)
1205{ 1205{
1206 Channel *c = NULL; 1206 Channel *c = NULL;
1207 int id, reply, success = 0; 1207 int id, reply, success = 0;
diff --git a/dispatch.c b/dispatch.c
index 64873d53a..036c0aaa5 100644
--- a/dispatch.c
+++ b/dispatch.c
@@ -22,7 +22,7 @@
22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */ 23 */
24#include "includes.h" 24#include "includes.h"
25RCSID("$OpenBSD: dispatch.c,v 1.11 2001/06/10 11:29:20 markus Exp $"); 25RCSID("$OpenBSD: dispatch.c,v 1.12 2001/12/20 22:50:24 djm Exp $");
26 26
27#include "ssh1.h" 27#include "ssh1.h"
28#include "ssh2.h" 28#include "ssh2.h"
@@ -37,9 +37,10 @@ RCSID("$OpenBSD: dispatch.c,v 1.11 2001/06/10 11:29:20 markus Exp $");
37dispatch_fn *dispatch[DISPATCH_MAX]; 37dispatch_fn *dispatch[DISPATCH_MAX];
38 38
39void 39void
40dispatch_protocol_error(int type, int plen, void *ctxt) 40dispatch_protocol_error(int type, int plen, u_int32_t seq, void *ctxt)
41{ 41{
42 fatal("dispatch_protocol_error: type %d plen %d", type, plen); 42 fatal("dispatch_protocol_error: type %d seq %u plen %d", type,
43 seq, plen);
43} 44}
44void 45void
45dispatch_init(dispatch_fn *dflt) 46dispatch_init(dispatch_fn *dflt)
@@ -59,16 +60,17 @@ dispatch_run(int mode, int *done, void *ctxt)
59 for (;;) { 60 for (;;) {
60 int plen; 61 int plen;
61 int type; 62 int type;
63 u_int32_t seqnr;
62 64
63 if (mode == DISPATCH_BLOCK) { 65 if (mode == DISPATCH_BLOCK) {
64 type = packet_read(&plen); 66 type = packet_read_seqnr(&plen, &seqnr);
65 } else { 67 } else {
66 type = packet_read_poll(&plen); 68 type = packet_read_poll_seqnr(&plen, &seqnr);
67 if (type == SSH_MSG_NONE) 69 if (type == SSH_MSG_NONE)
68 return; 70 return;
69 } 71 }
70 if (type > 0 && type < DISPATCH_MAX && dispatch[type] != NULL) 72 if (type > 0 && type < DISPATCH_MAX && dispatch[type] != NULL)
71 (*dispatch[type])(type, plen, ctxt); 73 (*dispatch[type])(type, plen, seqnr, ctxt);
72 else 74 else
73 packet_disconnect("protocol error: rcvd type %d", type); 75 packet_disconnect("protocol error: rcvd type %d", type);
74 if (done != NULL && *done) 76 if (done != NULL && *done)
diff --git a/dispatch.h b/dispatch.h
index 7b94032af..127ec1067 100644
--- a/dispatch.h
+++ b/dispatch.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: dispatch.h,v 1.6 2001/06/26 17:27:23 markus Exp $ */ 1/* $OpenBSD: dispatch.h,v 1.7 2001/12/20 22:50:24 djm Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2000 Markus Friedl. All rights reserved. 4 * Copyright (c) 2000 Markus Friedl. All rights reserved.
@@ -28,9 +28,9 @@ enum {
28 DISPATCH_NONBLOCK 28 DISPATCH_NONBLOCK
29}; 29};
30 30
31typedef void dispatch_fn(int, int, void *); 31typedef void dispatch_fn(int, int, u_int32_t, void *);
32 32
33void dispatch_init(dispatch_fn *); 33void dispatch_init(dispatch_fn *);
34void dispatch_set(int, dispatch_fn *); 34void dispatch_set(int, dispatch_fn *);
35void dispatch_run(int, int *, void *); 35void dispatch_run(int, int *, void *);
36void dispatch_protocol_error(int, int, void *); 36void dispatch_protocol_error(int, int, u_int32_t, void *);
diff --git a/kex.c b/kex.c
index 658da6d8a..8e3d83bef 100644
--- a/kex.c
+++ b/kex.c
@@ -23,7 +23,7 @@
23 */ 23 */
24 24
25#include "includes.h" 25#include "includes.h"
26RCSID("$OpenBSD: kex.c,v 1.37 2001/12/05 10:06:12 deraadt Exp $"); 26RCSID("$OpenBSD: kex.c,v 1.38 2001/12/20 22:50:24 djm Exp $");
27 27
28#include <openssl/crypto.h> 28#include <openssl/crypto.h>
29 29
@@ -107,7 +107,7 @@ kex_prop_free(char **proposal)
107} 107}
108 108
109static void 109static void
110kex_protocol_error(int type, int plen, void *ctxt) 110kex_protocol_error(int type, int plen, u_int32_t seq, void *ctxt)
111{ 111{
112 error("Hm, kex protocol error: type %d plen %d", type, plen); 112 error("Hm, kex protocol error: type %d plen %d", type, plen);
113} 113}
@@ -166,7 +166,7 @@ kex_send_kexinit(Kex *kex)
166} 166}
167 167
168void 168void
169kex_input_kexinit(int type, int plen, void *ctxt) 169kex_input_kexinit(int type, int plen, u_int32_t seq, void *ctxt)
170{ 170{
171 char *ptr; 171 char *ptr;
172 int dlen; 172 int dlen;
diff --git a/kex.h b/kex.h
index fe339211a..ba650ea05 100644
--- a/kex.h
+++ b/kex.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: kex.h,v 1.26 2001/06/26 17:27:23 markus Exp $ */ 1/* $OpenBSD: kex.h,v 1.27 2001/12/20 22:50:24 djm Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. 4 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
@@ -115,7 +115,7 @@ Kex *kex_setup(char *[PROPOSAL_MAX]);
115void kex_finish(Kex *); 115void kex_finish(Kex *);
116 116
117void kex_send_kexinit(Kex *); 117void kex_send_kexinit(Kex *);
118void kex_input_kexinit(int, int, void *); 118void kex_input_kexinit(int, int, u_int32_t, void *);
119void kex_derive_keys(Kex *, u_char *, BIGNUM *); 119void kex_derive_keys(Kex *, u_char *, BIGNUM *);
120 120
121void kexdh(Kex *); 121void kexdh(Kex *);
diff --git a/packet.c b/packet.c
index 4b3eafc88..17165b696 100644
--- a/packet.c
+++ b/packet.c
@@ -37,7 +37,7 @@
37 */ 37 */
38 38
39#include "includes.h" 39#include "includes.h"
40RCSID("$OpenBSD: packet.c,v 1.76 2001/12/19 17:16:13 stevesk Exp $"); 40RCSID("$OpenBSD: packet.c,v 1.77 2001/12/20 22:50:24 djm Exp $");
41 41
42#include "xmalloc.h" 42#include "xmalloc.h"
43#include "buffer.h" 43#include "buffer.h"
@@ -610,7 +610,7 @@ packet_send(void)
610 */ 610 */
611 611
612int 612int
613packet_read(int *payload_len_ptr) 613packet_read_seqnr(int *payload_len_ptr, u_int32_t *seqnr_p)
614{ 614{
615 int type, len; 615 int type, len;
616 fd_set *setp; 616 fd_set *setp;
@@ -626,7 +626,7 @@ packet_read(int *payload_len_ptr)
626 /* Stay in the loop until we have received a complete packet. */ 626 /* Stay in the loop until we have received a complete packet. */
627 for (;;) { 627 for (;;) {
628 /* Try to read a packet from the buffer. */ 628 /* Try to read a packet from the buffer. */
629 type = packet_read_poll(payload_len_ptr); 629 type = packet_read_poll_seqnr(payload_len_ptr, seqnr_p);
630 if (!compat20 && ( 630 if (!compat20 && (
631 type == SSH_SMSG_SUCCESS 631 type == SSH_SMSG_SUCCESS
632 || type == SSH_SMSG_FAILURE 632 || type == SSH_SMSG_FAILURE
@@ -665,6 +665,12 @@ packet_read(int *payload_len_ptr)
665 /* NOTREACHED */ 665 /* NOTREACHED */
666} 666}
667 667
668int
669packet_read(int *payload_len_ptr)
670{
671 return packet_read_seqnr(payload_len_ptr, NULL);
672}
673
668/* 674/*
669 * Waits until a packet has been received, verifies that its type matches 675 * Waits until a packet has been received, verifies that its type matches
670 * that given, and gives a fatal error and exits if there is a mismatch. 676 * that given, and gives a fatal error and exits if there is a mismatch.
@@ -753,7 +759,7 @@ packet_read_poll1(int *payload_len_ptr)
753 759
754 /* Test check bytes. */ 760 /* Test check bytes. */
755 if (len != buffer_len(&incoming_packet)) 761 if (len != buffer_len(&incoming_packet))
756 packet_disconnect("packet_read_poll: len %d != buffer_len %d.", 762 packet_disconnect("packet_read_poll1: len %d != buffer_len %d.",
757 len, buffer_len(&incoming_packet)); 763 len, buffer_len(&incoming_packet));
758 764
759 ucp = (u_char *) buffer_ptr(&incoming_packet) + len - 4; 765 ucp = (u_char *) buffer_ptr(&incoming_packet) + len - 4;
@@ -775,7 +781,7 @@ packet_read_poll1(int *payload_len_ptr)
775} 781}
776 782
777static int 783static int
778packet_read_poll2(int *payload_len_ptr) 784packet_read_poll2(int *payload_len_ptr, u_int32_t *seqnr_p)
779{ 785{
780 static u_int32_t seqnr = 0; 786 static u_int32_t seqnr = 0;
781 static u_int packet_length = 0; 787 static u_int packet_length = 0;
@@ -848,6 +854,8 @@ packet_read_poll2(int *payload_len_ptr)
848 DBG(debug("MAC #%d ok", seqnr)); 854 DBG(debug("MAC #%d ok", seqnr));
849 buffer_consume(&input, mac->mac_len); 855 buffer_consume(&input, mac->mac_len);
850 } 856 }
857 if (seqnr_p != NULL)
858 *seqnr_p = seqnr;
851 if (++seqnr == 0) 859 if (++seqnr == 0)
852 log("incoming seqnr wraps around"); 860 log("incoming seqnr wraps around");
853 861
@@ -890,7 +898,7 @@ packet_read_poll2(int *payload_len_ptr)
890} 898}
891 899
892int 900int
893packet_read_poll(int *payload_len_ptr) 901packet_read_poll_seqnr(int *payload_len_ptr, u_int32_t *seqnr_p)
894{ 902{
895 int reason; 903 int reason;
896 u_char type; 904 u_char type;
@@ -898,7 +906,7 @@ packet_read_poll(int *payload_len_ptr)
898 906
899 for (;;) { 907 for (;;) {
900 if (compat20) { 908 if (compat20) {
901 type = packet_read_poll2(payload_len_ptr); 909 type = packet_read_poll2(payload_len_ptr, seqnr_p);
902 if (type) 910 if (type)
903 DBG(debug("received packet type %d", type)); 911 DBG(debug("received packet type %d", type));
904 switch (type) { 912 switch (type) {
@@ -951,6 +959,12 @@ packet_read_poll(int *payload_len_ptr)
951 } 959 }
952} 960}
953 961
962int
963packet_read_poll(int *payload_len_ptr)
964{
965 return packet_read_poll_seqnr(payload_len_ptr, NULL);
966}
967
954/* 968/*
955 * Buffers the given amount of input characters. This is intended to be used 969 * Buffers the given amount of input characters. This is intended to be used
956 * together with packet_read_poll. 970 * together with packet_read_poll.
diff --git a/packet.h b/packet.h
index d281042f1..1cc79d47c 100644
--- a/packet.h
+++ b/packet.h
@@ -11,7 +11,7 @@
11 * called by a name other than "ssh" or "Secure Shell". 11 * called by a name other than "ssh" or "Secure Shell".
12 */ 12 */
13 13
14/* RCSID("$OpenBSD: packet.h,v 1.27 2001/12/19 17:16:13 stevesk Exp $"); */ 14/* RCSID("$OpenBSD: packet.h,v 1.28 2001/12/20 22:50:24 djm Exp $"); */
15 15
16#ifndef PACKET_H 16#ifndef PACKET_H
17#define PACKET_H 17#define PACKET_H
@@ -44,6 +44,8 @@ int packet_read(int *payload_len_ptr);
44void packet_read_expect(int *payload_len_ptr, int type); 44void packet_read_expect(int *payload_len_ptr, int type);
45int packet_read_poll(int *packet_len_ptr); 45int packet_read_poll(int *packet_len_ptr);
46void packet_process_incoming(const char *buf, u_int len); 46void packet_process_incoming(const char *buf, u_int len);
47int packet_read_seqnr(int *payload_len_ptr, u_int32_t *seqnr_p);
48int packet_read_poll_seqnr(int *packet_len_ptr, u_int32_t *seqnr_p);
47 49
48u_int packet_get_char(void); 50u_int packet_get_char(void);
49u_int packet_get_int(void); 51u_int packet_get_int(void);
diff --git a/serverloop.c b/serverloop.c
index c876dc0ca..0754fe76f 100644
--- a/serverloop.c
+++ b/serverloop.c
@@ -35,7 +35,7 @@
35 */ 35 */
36 36
37#include "includes.h" 37#include "includes.h"
38RCSID("$OpenBSD: serverloop.c,v 1.87 2001/12/19 16:09:39 markus Exp $"); 38RCSID("$OpenBSD: serverloop.c,v 1.88 2001/12/20 22:50:24 djm Exp $");
39 39
40#include "xmalloc.h" 40#include "xmalloc.h"
41#include "packet.h" 41#include "packet.h"
@@ -791,7 +791,7 @@ server_loop2(Authctxt *authctxt)
791} 791}
792 792
793static void 793static void
794server_input_channel_failure(int type, int plen, void *ctxt) 794server_input_channel_failure(int type, int plen, u_int32_t seq, void *ctxt)
795{ 795{
796 debug("Got CHANNEL_FAILURE for keepalive"); 796 debug("Got CHANNEL_FAILURE for keepalive");
797 /* 797 /*
@@ -804,7 +804,7 @@ server_input_channel_failure(int type, int plen, void *ctxt)
804 804
805 805
806static void 806static void
807server_input_stdin_data(int type, int plen, void *ctxt) 807server_input_stdin_data(int type, int plen, u_int32_t seq, void *ctxt)
808{ 808{
809 char *data; 809 char *data;
810 u_int data_len; 810 u_int data_len;
@@ -821,7 +821,7 @@ server_input_stdin_data(int type, int plen, void *ctxt)
821} 821}
822 822
823static void 823static void
824server_input_eof(int type, int plen, void *ctxt) 824server_input_eof(int type, int plen, u_int32_t seq, void *ctxt)
825{ 825{
826 /* 826 /*
827 * Eof from the client. The stdin descriptor to the 827 * Eof from the client. The stdin descriptor to the
@@ -834,7 +834,7 @@ server_input_eof(int type, int plen, void *ctxt)
834} 834}
835 835
836static void 836static void
837server_input_window_size(int type, int plen, void *ctxt) 837server_input_window_size(int type, int plen, u_int32_t seq, void *ctxt)
838{ 838{
839 int row = packet_get_int(); 839 int row = packet_get_int();
840 int col = packet_get_int(); 840 int col = packet_get_int();
@@ -912,7 +912,7 @@ server_request_session(char *ctype)
912} 912}
913 913
914static void 914static void
915server_input_channel_open(int type, int plen, void *ctxt) 915server_input_channel_open(int type, int plen, u_int32_t seq, void *ctxt)
916{ 916{
917 Channel *c = NULL; 917 Channel *c = NULL;
918 char *ctype; 918 char *ctype;
@@ -962,7 +962,7 @@ server_input_channel_open(int type, int plen, void *ctxt)
962} 962}
963 963
964static void 964static void
965server_input_global_request(int type, int plen, void *ctxt) 965server_input_global_request(int type, int plen, u_int32_t seq, void *ctxt)
966{ 966{
967 char *rtype; 967 char *rtype;
968 int want_reply; 968 int want_reply;
diff --git a/ssh.c b/ssh.c
index 9ec63ab9a..a768f8ff1 100644
--- a/ssh.c
+++ b/ssh.c
@@ -39,7 +39,7 @@
39 */ 39 */
40 40
41#include "includes.h" 41#include "includes.h"
42RCSID("$OpenBSD: ssh.c,v 1.152 2001/12/19 17:16:13 stevesk Exp $"); 42RCSID("$OpenBSD: ssh.c,v 1.153 2001/12/20 22:50:24 djm Exp $");
43 43
44#include <openssl/evp.h> 44#include <openssl/evp.h>
45#include <openssl/err.h> 45#include <openssl/err.h>
@@ -1015,7 +1015,7 @@ ssh_session(void)
1015} 1015}
1016 1016
1017static void 1017static void
1018client_subsystem_reply(int type, int plen, void *ctxt) 1018client_subsystem_reply(int type, int plen, u_int32_t seq, void *ctxt)
1019{ 1019{
1020 int id, len; 1020 int id, len;
1021 1021
diff --git a/sshconnect2.c b/sshconnect2.c
index 8689da087..d7143cd18 100644
--- a/sshconnect2.c
+++ b/sshconnect2.c
@@ -23,7 +23,7 @@
23 */ 23 */
24 24
25#include "includes.h" 25#include "includes.h"
26RCSID("$OpenBSD: sshconnect2.c,v 1.88 2001/12/19 07:18:56 deraadt Exp $"); 26RCSID("$OpenBSD: sshconnect2.c,v 1.89 2001/12/20 22:50:24 djm Exp $");
27 27
28#include <openssl/bn.h> 28#include <openssl/bn.h>
29#include <openssl/md5.h> 29#include <openssl/md5.h>
@@ -174,12 +174,12 @@ struct Authmethod {
174 int *batch_flag; /* flag in option struct that disables method */ 174 int *batch_flag; /* flag in option struct that disables method */
175}; 175};
176 176
177void input_userauth_success(int, int, void *); 177void input_userauth_success(int, int, u_int32_t, void *);
178void input_userauth_failure(int, int, void *); 178void input_userauth_failure(int, int, u_int32_t, void *);
179void input_userauth_banner(int, int, void *); 179void input_userauth_banner(int, int, u_int32_t, void *);
180void input_userauth_error(int, int, void *); 180void input_userauth_error(int, int, u_int32_t, void *);
181void input_userauth_info_req(int, int, void *); 181void input_userauth_info_req(int, int, u_int32_t, void *);
182void input_userauth_pk_ok(int, int, void *); 182void input_userauth_pk_ok(int, int, u_int32_t, void *);
183 183
184int userauth_none(Authctxt *); 184int userauth_none(Authctxt *);
185int userauth_pubkey(Authctxt *); 185int userauth_pubkey(Authctxt *);
@@ -308,13 +308,13 @@ userauth(Authctxt *authctxt, char *authlist)
308 } 308 }
309} 309}
310void 310void
311input_userauth_error(int type, int plen, void *ctxt) 311input_userauth_error(int type, int plen, u_int32_t seq, void *ctxt)
312{ 312{
313 fatal("input_userauth_error: bad message during authentication: " 313 fatal("input_userauth_error: bad message during authentication: "
314 "type %d", type); 314 "type %d", type);
315} 315}
316void 316void
317input_userauth_banner(int type, int plen, void *ctxt) 317input_userauth_banner(int type, int plen, u_int32_t seq, void *ctxt)
318{ 318{
319 char *msg, *lang; 319 char *msg, *lang;
320 debug3("input_userauth_banner"); 320 debug3("input_userauth_banner");
@@ -325,7 +325,7 @@ input_userauth_banner(int type, int plen, void *ctxt)
325 xfree(lang); 325 xfree(lang);
326} 326}
327void 327void
328input_userauth_success(int type, int plen, void *ctxt) 328input_userauth_success(int type, int plen, u_int32_t seq, void *ctxt)
329{ 329{
330 Authctxt *authctxt = ctxt; 330 Authctxt *authctxt = ctxt;
331 if (authctxt == NULL) 331 if (authctxt == NULL)
@@ -336,7 +336,7 @@ input_userauth_success(int type, int plen, void *ctxt)
336 authctxt->success = 1; /* break out */ 336 authctxt->success = 1; /* break out */
337} 337}
338void 338void
339input_userauth_failure(int type, int plen, void *ctxt) 339input_userauth_failure(int type, int plen, u_int32_t seq, void *ctxt)
340{ 340{
341 Authctxt *authctxt = ctxt; 341 Authctxt *authctxt = ctxt;
342 char *authlist = NULL; 342 char *authlist = NULL;
@@ -357,7 +357,7 @@ input_userauth_failure(int type, int plen, void *ctxt)
357 userauth(authctxt, authlist); 357 userauth(authctxt, authlist);
358} 358}
359void 359void
360input_userauth_pk_ok(int type, int plen, void *ctxt) 360input_userauth_pk_ok(int type, int plen, u_int32_t seq, void *ctxt)
361{ 361{
362 Authctxt *authctxt = ctxt; 362 Authctxt *authctxt = ctxt;
363 Key *key = NULL; 363 Key *key = NULL;
@@ -768,7 +768,7 @@ userauth_kbdint(Authctxt *authctxt)
768 * parse INFO_REQUEST, prompt user and send INFO_RESPONSE 768 * parse INFO_REQUEST, prompt user and send INFO_RESPONSE
769 */ 769 */
770void 770void
771input_userauth_info_req(int type, int plen, void *ctxt) 771input_userauth_info_req(int type, int plen, u_int32_t seq, void *ctxt)
772{ 772{
773 Authctxt *authctxt = ctxt; 773 Authctxt *authctxt = ctxt;
774 char *name, *inst, *lang, *prompt, *response; 774 char *name, *inst, *lang, *prompt, *response;