]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
http: fix nul deref on memcap reached
authorPhilippe Antoine <pantoine@oisf.net>
Fri, 17 May 2024 07:39:52 +0000 (09:39 +0200)
committerVictor Julien <victor@inliniac.net>
Wed, 22 May 2024 04:45:09 +0000 (06:45 +0200)
HttpRangeOpenFileAux may return NULL in different cases, including
when memcap is reached.
But is only caller did not check it before calling HttpRangeAppendData
which would dereference the NULL value.

Ticket: 7029

src/app-layer-htp-range.c

index 3cdde35ba288fcfb59e7510bca2b9e0c802ad9ee..f0d75a9750c05a2005d866d3865884efcfa500f7 100644 (file)
@@ -351,8 +351,10 @@ static HttpRangeContainerBlock *HttpRangeOpenFile(HttpRangeContainerFile *c, uin
 {
     HttpRangeContainerBlock *r =
             HttpRangeOpenFileAux(c, start, end, total, sbcfg, name, name_len, flags);
-    if (HttpRangeAppendData(sbcfg, r, data, len) < 0) {
-        SCLogDebug("Failed to append data while opening");
+    if (r) {
+        if (HttpRangeAppendData(sbcfg, r, data, len) < 0) {
+            SCLogDebug("Failed to append data while opening");
+        }
     }
     return r;
 }