Skip to content

Commit 82af0ae

Browse files
committed
swf: prevents overflow with bad config value
Ticket: 8642 Do not allocate too much by using the config value, when the flash file does not require that much data anyways (cherry picked from commit d9fae18)
1 parent 3dc8217 commit 82af0ae

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/util-file-decompression.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,13 @@ int FileSwfDecompression(const uint8_t *buffer, uint32_t buffer_len,
125125
}
126126

127127
/* if decompress_depth is 0, keep the flash file length */
128-
uint32_t decompressed_data_len = (decompress_depth == 0) ? decompressed_swf_len : decompress_depth;
128+
uint32_t decompressed_data_len = decompressed_swf_len;
129+
// only restrict the decompressed_data_len, a too big decompress_depth does not make us more
130+
// than we need
131+
if (decompress_depth > 0 && decompress_depth < decompressed_data_len)
132+
decompressed_data_len = decompress_depth;
133+
134+
// cannot overflow as decompressed_swf_len maxed out at MAX_SWF_DECOMPRESSED_LEN 50000000
129135
decompressed_data_len += 8;
130136

131137
/* make sure the inspection buffer has enough space */

0 commit comments

Comments
 (0)