]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect/prefilter: fix coverity issue
authorVictor Julien <vjulien@oisf.net>
Tue, 8 Apr 2025 18:05:22 +0000 (20:05 +0200)
committerVictor Julien <vjulien@oisf.net>
Wed, 9 Apr 2025 07:34:04 +0000 (09:34 +0200)
** CID 1646448:  Null pointer dereferences  (NULL_RETURNS)
/src/detect-engine-prefilter.c: 944 in SetupNonPrefilter()

________________________________________________________________________________________________________
*** CID 1646448:  Null pointer dereferences  (NULL_RETURNS)
/src/detect-engine-prefilter.c: 944 in SetupNonPrefilter()
938                 const DetectBufferType *buf = DetectEngineBufferTypeGetById(de_ctx, list_id);
939                 /* for now, exclude app-layer-events, as they are not tied to a specific
940                  * progress value like other keywords. */
941                 SCLogDebug("list_id %d buf %p", list_id, buf);
942                 if (list_id == app_events_list_id)
943                     continue;
>>>     CID 1646448:  Null pointer dereferences  (NULL_RETURNS)
>>>     Dereferencing "buf", which is known to be "NULL".
944                 if (buf->packet) {
945                     SCLogDebug("packet buf");
946                     /* packet is handled below */
947                     pkt_non_pf = true;
948                 } else if (buf->frame) {
949                     for (DetectEngineFrameInspectionEngine *f = de_ctx->frame_inspect_engines;

src/detect-engine-prefilter.c

index bf0b9984fb9939c3a8aeb1cdd00b1e5d5591c72e..37e71675753f60bcef86ec77bdf67d1d93cfaf85 100644 (file)
@@ -936,6 +936,8 @@ static int SetupNonPrefilter(DetectEngineCtx *de_ctx, SigGroupHead *sgh)
         for (uint32_t x = 0; x < s->init_data->buffer_index; x++) {
             const int list_id = s->init_data->buffers[x].id;
             const DetectBufferType *buf = DetectEngineBufferTypeGetById(de_ctx, list_id);
+            if (buf == NULL)
+                continue;
             /* for now, exclude app-layer-events, as they are not tied to a specific
              * progress value like other keywords. */
             SCLogDebug("list_id %d buf %p", list_id, buf);