]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
flash: code cleanups 3246/head
authorVictor Julien <victor@inliniac.net>
Fri, 2 Feb 2018 14:45:47 +0000 (15:45 +0100)
committerVictor Julien <victor@inliniac.net>
Wed, 14 Feb 2018 13:25:46 +0000 (14:25 +0100)
src/util-file-decompression.c
src/util-file-swf-decompression.c
src/util-file-swf-decompression.h

index 9d561e0833453f34de9f5ee2c5e76e85f409d2d3..43f323f5c0cc07e0d46bb595c87450cbd261f8d1 100644 (file)
@@ -165,17 +165,16 @@ int FileSwfDecompression(const uint8_t *buffer, uint32_t buffer_len,
     } else if ((swf_type == HTTP_SWF_COMPRESSION_LZMA || swf_type == HTTP_SWF_COMPRESSION_BOTH) &&
                compression_type == FILE_SWF_LZMA_COMPRESSION)
     {
+#ifndef HAVE_LIBLZMA
+        goto error;
+#else
         /* we need to setup the lzma header */
         /*
          * | 5 bytes         | 8 bytes             | n bytes         |
          * | LZMA properties | Uncompressed length | Compressed data |
          */
         compressed_data_len += 13;
-        uint8_t *compressed_data = SCMalloc(compressed_data_len);
-        if (compressed_data == NULL) {
-            DetectEngineSetEvent(det_ctx, FILE_DECODER_EVENT_NO_MEM);
-            goto error;
-        }
+        uint8_t compressed_data[compressed_data_len];
         /* put lzma properties */
         memcpy(compressed_data, buffer + 12, 5);
         /* put lzma end marker */
@@ -189,9 +188,9 @@ 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;
+#endif
     } else {
         goto error;
     }
index 81b07d816330ed9002640b254cdb666b59d9429a..aeb6fdfdf6efa9323780f7abbb53778dfdb71b7e 100644 (file)
@@ -125,11 +125,11 @@ int FileSwfZlibDecompression(DetectEngineThreadCtx *det_ctx,
  * | 4 bytes         | 4 bytes    | 4 bytes        | 5 bytes    | n bytes   | 6 bytes         |
  * | 'ZWS' + version | script len | compressed len | LZMA props | LZMA data | LZMA end marker |
  */
+#ifdef HAVE_LIBLZMA
 int FileSwfLzmaDecompression(DetectEngineThreadCtx *det_ctx,
                              uint8_t *compressed_data, uint32_t compressed_data_len,
                              uint8_t *decompressed_data, uint32_t decompressed_data_len)
 {
-#ifdef HAVE_LIBLZMA
     int ret = 1;
     lzma_stream strm = LZMA_STREAM_INIT;
     lzma_ret result = lzma_alone_decoder(&strm, UINT64_MAX /* memlimit */);
@@ -177,7 +177,5 @@ int FileSwfLzmaDecompression(DetectEngineThreadCtx *det_ctx,
 
     lzma_end(&strm);
     return ret;
-#else
-    return 0;
-#endif /* HAVE_LIBLZMA */
 }
+#endif /* HAVE_LIBLZMA */
index aa2af4b10600823a69738c5bfdbc133e4c6aad51..79034b89e47b0d324834c502f47ed9d9c280f3dc 100644 (file)
@@ -35,8 +35,10 @@ uint32_t FileGetSwfDecompressedLen(const uint8_t *buffer, uint32_t buffr_len);
 int FileSwfZlibDecompression(DetectEngineThreadCtx *det_ctx,
                              uint8_t *compressed_data, uint32_t compressed_data_len,
                              uint8_t *decompressed_data, uint32_t decompressed_data_len);
+#ifdef HAVE_LIBLZMA
 int FileSwfLzmaDecompression(DetectEngineThreadCtx *det_ctx,
                              uint8_t *compressed_data, uint32_t compressed_data_len,
                              uint8_t *decompressed_data, uint32_t decompressed_data_len);
+#endif
 
 #endif /* __UTIL_FILE_SWF_DECOMPRESSION_H__ */