From ac381e055bf6c0016b5e0246cf30378209f11233 Mon Sep 17 00:00:00 2001 From: Fernando Alves Date: Sun, 17 Sep 2023 14:41:05 +0200 Subject: [PATCH] fix infinite loop --- l2tpns.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/l2tpns.c b/l2tpns.c index 152c8ec..5947561 100644 --- a/l2tpns.c +++ b/l2tpns.c @@ -2716,7 +2716,14 @@ void processudp(uint8_t *buf, int len, struct sockaddr_in *addr, uint16_t indexu result = 2; // general error error = 3; // reserved field non-zero msg = 0; - continue; // next + if (n == 0) + { + // if continue a infinity loop is created. + LOG(1, s, t, "It's infinite loop protection %02X\n", *b); + return; + } + else + continue; // next } b += 2; if (*(uint16_t *) (b)) @@ -2726,7 +2733,14 @@ void processudp(uint8_t *buf, int len, struct sockaddr_in *addr, uint16_t indexu result = 2; // general error error = 6; // generic vendor-specific error msg = "unsupported vendor-specific"; - continue; // next + if (n == 0) + { + // if continue a infinity loop is created. + LOG(1, s, t, "It's infinite loop protection %02X\n", *b); + return; + } + else + continue; // next } b += 2; mtype = ntohs(*(uint16_t *) (b)); -- 2.20.1