summaryrefslogtreecommitdiffstats
path: root/packet.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2016-10-11 21:47:45 +0000
committerDamien Miller <djm@mindrot.org>2016-10-13 18:55:25 +1100
commit39af7b444db28c1cb01b7ea468a4f574a44f375b (patch)
treefcfba47f83bd07ba4ee90fc5dc4b2a641c412075 /packet.c
parentec165c392ca54317dbe3064a8c200de6531e89ad (diff)
upstream commit
Add a per-packet input hook that is called with the decrypted packet contents. This will be used for fuzzing; ok markus@ Upstream-ID: a3221cee6b1725dd4ae1dd2c13841b4784cb75dc
Diffstat (limited to 'packet.c')
-rw-r--r--packet.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/packet.c b/packet.c
index 783ae5bd..ad1f6b49 100644
--- a/packet.c
+++ b/packet.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: packet.c,v 1.242 2016/09/30 09:19:13 markus Exp $ */
+/* $OpenBSD: packet.c,v 1.243 2016/10/11 21:47:45 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -219,6 +219,10 @@ struct session_state {
/* SSH1 CRC compensation attack detector */
struct deattack_ctx deattack;
+ /* Hook for fuzzing inbound packets */
+ ssh_packet_hook_fn *hook_in;
+ void *hook_in_ctx;
+
TAILQ_HEAD(, packet) outgoing;
};
@@ -263,6 +267,13 @@ ssh_alloc_session_state(void)
return NULL;
}
+void
+ssh_packet_set_input_hook(struct ssh *ssh, ssh_packet_hook_fn *hook, void *ctx)
+{
+ ssh->state->hook_in = hook;
+ ssh->state->hook_in_ctx = ctx;
+}
+
/* Returns nonzero if rekeying is in progress */
int
ssh_packet_is_rekeying(struct ssh *ssh)
@@ -1884,6 +1895,10 @@ ssh_packet_read_poll2(struct ssh *ssh, u_char *typep, u_int32_t *seqnr_p)
return r;
return SSH_ERR_PROTOCOL_ERROR;
}
+ if (state->hook_in != NULL &&
+ (r = state->hook_in(ssh, state->incoming_packet, typep,
+ state->hook_in_ctx)) != 0)
+ return r;
if (*typep == SSH2_MSG_USERAUTH_SUCCESS && !state->server_side)
r = ssh_packet_enable_delayed_compress(ssh);
else