summaryrefslogtreecommitdiff
path: root/lib/sqfs
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-27 15:17:37 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-27 15:17:37 +0200
commitf45b36ed81bf3b33f030c769f696e028216ef609 (patch)
treeb4435deed24f84e2d3009d124c3809d58bd45a39 /lib/sqfs
parentacce940aa48678632e58d0befacdc2787f1e43bf (diff)
Fix lzma compressor: test if compression actually shrunk the data
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs')
-rw-r--r--lib/sqfs/comp/lzma.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/sqfs/comp/lzma.c b/lib/sqfs/comp/lzma.c
index 82590c7..9fc507f 100644
--- a/lib/sqfs/comp/lzma.c
+++ b/lib/sqfs/comp/lzma.c
@@ -69,6 +69,9 @@ static ssize_t lzma_comp_block(sqfs_compressor_t *base, const uint8_t *in,
if (ret != LZMA_STREAM_END)
return ret == LZMA_OK ? 0 : SQFS_ERROR_COMRPESSOR;
+ if (strm.total_out > size)
+ return 0;
+
out[LZMA_SIZE_OFFSET ] = size & 0xFF;
out[LZMA_SIZE_OFFSET + 1] = (size >> 8) & 0xFF;
out[LZMA_SIZE_OFFSET + 2] = (size >> 16) & 0xFF;