} 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 */
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;
}
* | 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 */);
lzma_end(&strm);
return ret;
-#else
- return 0;
-#endif /* HAVE_LIBLZMA */
}
+#endif /* HAVE_LIBLZMA */
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__ */