]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
decode/pppoe: skip useless loop unless debug 10615/head 10618/head
authorPhilippe Antoine <pantoine@oisf.net>
Mon, 11 Mar 2024 14:58:24 +0000 (15:58 +0100)
committerPhilippe Antoine <pantoine@oisf.net>
Mon, 11 Mar 2024 15:00:05 +0000 (16:00 +0100)
Looping over tags has no effects, except debug logging

src/decode-pppoe.c

index cb6eccb6b4e757ed577e8507c059365fee474dc8..eb5e6acb28447ac3dd7c9dcb38de633b850b46e3 100644 (file)
@@ -80,11 +80,6 @@ int DecodePPPOEDiscovery(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
             return TM_ECODE_OK;
     }
 
-    /* parse any tags we have in the packet */
-
-    uint32_t tag_length = 0;
-    const uint8_t* pkt_pppoedt = pkt + PPPOE_DISCOVERY_HEADER_MIN_LEN;
-
     uint32_t pppoe_length = SCNtohs(p->pppoedh->pppoe_length);
     uint32_t packet_length = len - PPPOE_DISCOVERY_HEADER_MIN_LEN ;
 
@@ -97,13 +92,16 @@ int DecodePPPOEDiscovery(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
         return TM_ECODE_OK;
     }
 
-    // packet_length >= pppoe_length so we have enough data
-    while (pppoe_length >= sizeof(PPPOEDiscoveryTag))
-    {
-        PPPOEDiscoveryTag* pppoedt = (PPPOEDiscoveryTag*)pkt_pppoedt;
 #ifdef DEBUG
+    /* parse any tags we have in the packet */
+
+    uint32_t tag_length = 0;
+    const uint8_t *pkt_pppoedt = pkt + PPPOE_DISCOVERY_HEADER_MIN_LEN;
+
+    // packet_length >= pppoe_length so we have enough data
+    while (pppoe_length >= sizeof(PPPOEDiscoveryTag)) {
+        PPPOEDiscoveryTag *pppoedt = (PPPOEDiscoveryTag *)pkt_pppoedt;
         uint16_t tag_type = SCNtohs(pppoedt->pppoe_tag_type);
-#endif
         // upgrade to u32 to avoid u16 overflow
         tag_length = SCNtohs(pppoedt->pppoe_tag_length);
 
@@ -116,6 +114,7 @@ int DecodePPPOEDiscovery(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
             pppoe_length = 0; // don't want an underflow
         }
     }
+#endif
 
     return TM_ECODE_OK;
 }