]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
util/swf: move allocation from stack to heap
authorPhilippe Antoine <pantoine@oisf.net>
Thu, 30 Oct 2025 10:27:22 +0000 (11:27 +0100)
committerVictor Julien <vjulien@oisf.net>
Tue, 4 Nov 2025 16:33:07 +0000 (17:33 +0100)
As it can overflow the stack

Ticket: 8055

src/util-file-decompression.c

index ffff78e388c8fa906f7a08d2a82fd760d455e117..9d7af2edf117550906e90ee1829b5dfb4a048b17 100644 (file)
@@ -169,7 +169,10 @@ int FileSwfDecompression(const uint8_t *buffer, uint32_t buffer_len,
          * | LZMA properties | Uncompressed length | Compressed data |
          */
         compressed_data_len += 13;
-        uint8_t compressed_data[compressed_data_len];
+        uint8_t *compressed_data = SCCalloc(1, compressed_data_len);
+        if (compressed_data == NULL) {
+            goto error;
+        }
         /* put lzma properties */
         memcpy(compressed_data, buffer + 12, 5);
         /* put lzma end marker */
@@ -183,6 +186,7 @@ int FileSwfDecompression(const uint8_t *buffer, uint32_t buffer_len,
         r = FileSwfLzmaDecompression(det_ctx,
                                      compressed_data, compressed_data_len,
                                      out_buffer->buf + 8, out_buffer->len - 8);
+        SCFree(compressed_data);
         if (r == 0)
             goto error;
     } else {