From 45207e0fb2c46e211ff2e66fb141867d81198d97 Mon Sep 17 00:00:00 2001 From: Gabriel Oginski Date: Tue, 22 Feb 2022 14:15:11 +0000 Subject: wireguard: fix dereferences null pointer Type: fix Fixed coverity-issue CID 248517. Originally possible passing null pointer to one function and directly dereferences it. This patch fixes the issue by add a new condition to check this pointer. Change-Id: If506abaf08c9f003860b641971af291f68613c18 Signed-off-by: Gabriel Oginski --- src/plugins/wireguard/wireguard_input.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/plugins/wireguard/wireguard_input.c') diff --git a/src/plugins/wireguard/wireguard_input.c b/src/plugins/wireguard/wireguard_input.c index ba5a1d679e2..7db1a0ccfec 100644 --- a/src/plugins/wireguard/wireguard_input.c +++ b/src/plugins/wireguard/wireguard_input.c @@ -902,10 +902,17 @@ wg_input_post (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame) last_rec_idx = data->receiver_index; } - ASSERT (peer != NULL); /* this pointer never should be NULL */ - if (PREDICT_FALSE (wg_input_post_process (vm, b[0], next, peer, data, - &is_keepalive) < 0)) - goto trace; + if (PREDICT_TRUE (peer != NULL)) + { + if (PREDICT_FALSE (wg_input_post_process (vm, b[0], next, peer, data, + &is_keepalive) < 0)) + goto trace; + } + else + { + next[0] = WG_INPUT_NEXT_PUNT; + goto trace; + } if (PREDICT_FALSE (peer_idx && (last_peer_time_idx != peer_idx))) { -- cgit 1.2.3-korg