fix infinite loop
authorFernando Alves <falves@maltem.com>
Sun, 17 Sep 2023 12:41:05 +0000 (14:41 +0200)
committerFernando Alves <falves@maltem.com>
Sun, 17 Sep 2023 12:41:05 +0000 (14:41 +0200)
l2tpns.c

index 152c8ec..5947561 100644 (file)
--- 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));