From 7336ffbd41b0132d1a89ee20d46db3b47e459192 Mon Sep 17 00:00:00 2001 From: emanuele-f Date: Fri, 20 May 2022 15:35:17 +0200 Subject: [PATCH] Ensure zdtun_parse_pkt initializes the zdtun_pkt_t --- zdtun.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zdtun.c b/zdtun.c index 9f30799..7554b72 100644 --- a/zdtun.c +++ b/zdtun.c @@ -876,13 +876,13 @@ static int is_upper_layer(int proto) { /* ******************************************************* */ int zdtun_parse_pkt(zdtun_t *tun, const char *_pkt_buf, uint16_t pkt_len, zdtun_pkt_t *pkt) { - if (pkt_len < IPV4_HEADER_LEN) { + memset(pkt, 0, sizeof(zdtun_pkt_t)); + + if(pkt_len < IPV4_HEADER_LEN) { debug("Ignoring non IP packet (len: %d)", pkt_len); return -1; } - memset(pkt, 0, sizeof(zdtun_pkt_t)); - char *pkt_buf = (char *)_pkt_buf; /* needed to set the zdtun_pkt_t pointers */ uint8_t ipver = (*pkt_buf) >> 4; uint8_t ipproto;