]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
defrag: remove tracker on frag pool issues
authorVictor Julien <vjulien@oisf.net>
Fri, 24 May 2024 17:14:10 +0000 (19:14 +0200)
committerVictor Julien <victor@inliniac.net>
Tue, 4 Jun 2024 04:28:26 +0000 (06:28 +0200)
If a frag wasn't inserted due to pool empty or alloc failure, clear and

invalidate the tracker.

src/defrag.c

index c20aefc2afbb319fd844c1870352ee1b34a00fc3..3802bba392c73608f81596ae5cf446734962546a 100644 (file)
@@ -872,7 +872,7 @@ DefragInsertFrag(ThreadVars *tv, DecodeThreadVars *dtv, DefragTracker *tracker,
         } else {
             ENGINE_SET_EVENT(p, IPV6_FRAG_IGNORED);
         }
-        goto done;
+        goto error_remove_tracker;
     }
     new->pkt = SCMalloc(GET_PKT_LEN(p));
     if (new->pkt == NULL) {
@@ -884,7 +884,7 @@ DefragInsertFrag(ThreadVars *tv, DecodeThreadVars *dtv, DefragTracker *tracker,
         } else {
             ENGINE_SET_EVENT(p, IPV6_FRAG_IGNORED);
         }
-        goto done;
+        goto error_remove_tracker;
     }
     memcpy(new->pkt, GET_PKT_DATA(p) + ltrim, GET_PKT_LEN(p) - ltrim);
     new->len = (GET_PKT_LEN(p) - ltrim);
@@ -965,6 +965,10 @@ done:
         }
     }
     return r;
+error_remove_tracker:
+    tracker->remove = 1;
+    DefragTrackerFreeFrags(tracker);
+    return NULL;
 }
 
 /**