Skip to content

Commit

Permalink
Ensure zdtun_parse_pkt initializes the zdtun_pkt_t
Browse files Browse the repository at this point in the history
  • Loading branch information
emanuele-f committed May 20, 2022
1 parent 611c546 commit 7336ffb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions zdtun.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 7336ffb

Please sign in to comment.