From dbbdfedb98d027f5115455837148e3345216473d Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Tue, 27 Aug 2019 10:48:50 +0200 Subject: [PATCH] lzma: make mandatory Libhtp is starting to use it as well, so its safe to make it mandatory here. Remove guards for flash file decompression code. --- configure.ac | 14 ++++++-------- src/tests/detect-http-server-body.c | 8 -------- src/util-file-decompression.c | 4 ---- src/util-file-swf-decompression.c | 4 ---- src/util-file-swf-decompression.h | 2 -- 5 files changed, 6 insertions(+), 26 deletions(-) diff --git a/configure.ac b/configure.ac index 61253e2e10..4b0dbfd4aa 100644 --- a/configure.ac +++ b/configure.ac @@ -603,24 +603,22 @@ if test "$with_liblzma_libraries" != "no"; then LDFLAGS="${LDFLAGS} -L${with_liblzma_libraries}" LIBS="${TMPLIBS} -llzma" - else - LIBS="${TMPLIBS} -llzma" + else + LIBS="${TMPLIBS} -llzma" fi fi]),LIBLZMA="no") if test "$LIBLZMA" != "yes"; then echo - echo " Warning! liblzma library not found, you will not be" - echo " able to decompress flash file compressed with lzma." + echo " Error! liblzma library not found." echo " Debian/Ubuntu: apt install liblzma-dev" echo " Fedora: dnf install xz-devel" echo " CentOS/RHEL: yum install xz-devel" echo - enable_liblzma=no - else - enable_liblzma=yes - LIBS="${TMPLIBS} -llzma" + exit 1 fi + enable_liblzma=yes + LIBS="${TMPLIBS} -llzma" #libpcre AC_ARG_WITH(libpcre_includes, diff --git a/src/tests/detect-http-server-body.c b/src/tests/detect-http-server-body.c index 2c768e3a29..3b63794930 100644 --- a/src/tests/detect-http-server-body.c +++ b/src/tests/detect-http-server-body.c @@ -4638,7 +4638,6 @@ libhtp:\n\ static int DetectEngineHttpServerBodyFileDataTest24(void) { -#ifdef HAVE_LIBLZMA char input[] = "\ %YAML 1.1\n\ ---\n\ @@ -4763,9 +4762,6 @@ libhtp:\n\ UTHFreePackets(&p1, 1); UTHFreePackets(&p2, 1); PASS; -#else - PASS; -#endif /* HAVE_LIBLZMA */ } static int DetectEngineHttpServerBodyFileDataTest25(void) @@ -4895,7 +4891,6 @@ libhtp:\n\ static int DetectEngineHttpServerBodyFileDataTest26(void) { -#ifdef HAVE_LIBLZMA char input[] = "\ %YAML 1.1\n\ ---\n\ @@ -5019,9 +5014,6 @@ libhtp:\n\ UTHFreePackets(&p1, 1); UTHFreePackets(&p2, 1); PASS; -#else - PASS; -#endif /* HAVE_LIBLZMA */ } static int DetectEngineHttpServerBodyFileDataTest27(void) diff --git a/src/util-file-decompression.c b/src/util-file-decompression.c index 43f323f5c0..9009845a10 100644 --- a/src/util-file-decompression.c +++ b/src/util-file-decompression.c @@ -165,9 +165,6 @@ 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 | @@ -190,7 +187,6 @@ int FileSwfDecompression(const uint8_t *buffer, uint32_t buffer_len, out_buffer->buf + 8, out_buffer->len - 8); if (r == 0) goto error; -#endif } else { goto error; } diff --git a/src/util-file-swf-decompression.c b/src/util-file-swf-decompression.c index 685f982097..fbdc275e9f 100644 --- a/src/util-file-swf-decompression.c +++ b/src/util-file-swf-decompression.c @@ -34,9 +34,7 @@ #include -#ifdef HAVE_LIBLZMA #include -#endif #define MAX_SWF_DECOMPRESSED_LEN 50000000 /* @@ -130,7 +128,6 @@ 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) @@ -183,4 +180,3 @@ int FileSwfLzmaDecompression(DetectEngineThreadCtx *det_ctx, lzma_end(&strm); return ret; } -#endif /* HAVE_LIBLZMA */ diff --git a/src/util-file-swf-decompression.h b/src/util-file-swf-decompression.h index 79034b89e4..aa2af4b106 100644 --- a/src/util-file-swf-decompression.h +++ b/src/util-file-swf-decompression.h @@ -35,10 +35,8 @@ 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__ */