summaryrefslogtreecommitdiff
path: root/dispatch.c
diff options
context:
space:
mode:
authorAlistair Delva <adelva@google.com>2020-08-21 00:00:13 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2020-08-21 00:00:13 +0000
commited358b3546c776c1c677fd88eb8f716cf6187510 (patch)
tree3c6134bcb2cda4b9dccc57b4a8b997a945aab62d /dispatch.c
parent22246b08952d746a7cc5a292570636cf4277598f (diff)
parent44a1065de8a58c51a021243a28bfa01e87822e4f (diff)
Merge changes I934c73d4,I28cdc9a0,I9e734da9,I3c079d86
* changes: UPSTREAM: depend UPSTREAM: upstream: avoid possible NULL deref; from Pedro Martelletto Revert "upstream: fix compilation with DEBUG_KEXDH; bz#3160 ok dtucker@" Merge upstream-master into master
Diffstat (limited to 'dispatch.c')
-rw-r--r--dispatch.c41
1 files changed, 9 insertions, 32 deletions
diff --git a/dispatch.c b/dispatch.c
index afe61822..6e4c501e 100644
--- a/dispatch.c
+++ b/dispatch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dispatch.c,v 1.26 2015/02/12 20:34:19 dtucker Exp $ */
+/* $OpenBSD: dispatch.c,v 1.32 2019/01/19 21:33:13 djm Exp $ */
/*
* Copyright (c) 2000 Markus Friedl. All rights reserved.
*
@@ -30,7 +30,6 @@
#include <signal.h>
#include <stdarg.h>
-#include "ssh1.h"
#include "ssh2.h"
#include "log.h"
#include "dispatch.h"
@@ -39,24 +38,21 @@
#include "ssherr.h"
int
-dispatch_protocol_error(int type, u_int32_t seq, void *ctx)
+dispatch_protocol_error(int type, u_int32_t seq, struct ssh *ssh)
{
- struct ssh *ssh = active_state; /* XXX */
int r;
logit("dispatch_protocol_error: type %d seq %u", type, seq);
- if (!compat20)
- fatal("protocol error");
if ((r = sshpkt_start(ssh, SSH2_MSG_UNIMPLEMENTED)) != 0 ||
(r = sshpkt_put_u32(ssh, seq)) != 0 ||
(r = sshpkt_send(ssh)) != 0 ||
(r = ssh_packet_write_wait(ssh)) != 0)
- sshpkt_fatal(ssh, __func__, r);
+ sshpkt_fatal(ssh, r, "%s", __func__);
return 0;
}
int
-dispatch_protocol_ignore(int type, u_int32_t seq, void *ssh)
+dispatch_protocol_ignore(int type, u_int32_t seq, struct ssh *ssh)
{
logit("dispatch_protocol_ignore: type %d seq %u", type, seq);
return 0;
@@ -89,8 +85,7 @@ ssh_dispatch_set(struct ssh *ssh, int type, dispatch_fn *fn)
}
int
-ssh_dispatch_run(struct ssh *ssh, int mode, volatile sig_atomic_t *done,
- void *ctxt)
+ssh_dispatch_run(struct ssh *ssh, int mode, volatile sig_atomic_t *done)
{
int r;
u_char type;
@@ -115,8 +110,7 @@ ssh_dispatch_run(struct ssh *ssh, int mode, volatile sig_atomic_t *done,
ssh->dispatch_skip_packets--;
continue;
}
- /* XXX 'ssh' will replace 'ctxt' later */
- r = (*ssh->dispatch[type])(type, seqnr, ctxt);
+ r = (*ssh->dispatch[type])(type, seqnr, ssh);
if (r != 0)
return r;
} else {
@@ -132,27 +126,10 @@ ssh_dispatch_run(struct ssh *ssh, int mode, volatile sig_atomic_t *done,
}
void
-ssh_dispatch_run_fatal(struct ssh *ssh, int mode, volatile sig_atomic_t *done,
- void *ctxt)
+ssh_dispatch_run_fatal(struct ssh *ssh, int mode, volatile sig_atomic_t *done)
{
int r;
- if ((r = ssh_dispatch_run(ssh, mode, done, ctxt)) != 0) {
- switch (r) {
- case SSH_ERR_CONN_CLOSED:
- logit("Connection closed by %.200s",
- ssh_remote_ipaddr(ssh));
- cleanup_exit(255);
- case SSH_ERR_CONN_TIMEOUT:
- logit("Connection to %.200s timed out while "
- "waiting to read", ssh_remote_ipaddr(ssh));
- cleanup_exit(255);
- case SSH_ERR_DISCONNECTED:
- logit("Disconnected from %.200s",
- ssh_remote_ipaddr(ssh));
- cleanup_exit(255);
- default:
- fatal("%s: %s", __func__, ssh_err(r));
- }
- }
+ if ((r = ssh_dispatch_run(ssh, mode, done)) != 0)
+ sshpkt_fatal(ssh, r, "%s", __func__);
}