diff options
author | Daniel Friesel <derf@finalrewind.org> | 2021-01-20 20:45:52 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2021-01-20 20:45:52 +0100 |
commit | 1a8998393fea87e1ba8f672f0f1fbd540448e54f (patch) | |
tree | dc342b7e974864824537f39e17f7bd96cdb095c3 | |
parent | cb2f614cd8cea5a03d1e365a176f45e27a60faf8 (diff) |
udeflate: Verify zlib FCHECK
-rw-r--r-- | include/lib/udeflate.h | 1 | ||||
-rw-r--r-- | src/lib/udeflate.cc | 4 |
2 files changed, 5 insertions, 0 deletions
diff --git a/include/lib/udeflate.h b/include/lib/udeflate.h index f3b1ff6..5e07422 100644 --- a/include/lib/udeflate.h +++ b/include/lib/udeflate.h @@ -12,6 +12,7 @@ #define UDEFLATE_ERR_BLOCK (-4) #define UDEFLATE_ERR_CHECKSUM (-5) #define UDEFLATE_ERR_OUTPUT_LENGTH (-6) +#define UDEFLATE_ERR_FCHECK (-7) int8_t udeflate(unsigned char *input_buf, uint16_t input_len, unsigned char *output_buf, uint16_t output_len); diff --git a/src/lib/udeflate.cc b/src/lib/udeflate.cc index baab208..5cd7973 100644 --- a/src/lib/udeflate.cc +++ b/src/lib/udeflate.cc @@ -422,6 +422,10 @@ int8_t udeflate_zlib(unsigned char *input_buf, uint16_t input_len, return UDEFLATE_ERR_FDICT; } + if ((((uint16_t)input_buf[0] << 8) | input_buf[1]) % 31) { + return UDEFLATE_ERR_FCHECK; + } + uint8_t ret = udeflate(input_buf + 2, input_len - 2, output_buf, output_len); |