summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-27 23:39:48 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-28 00:06:07 +0200
commit5d0a3f4599e33f32239aa1c9ad5d2741efed653f (patch)
treea9d722df8002f17cd1e17316d4d598c0cd26f200
parent1cf9256b38465989ac2fedfdb8a6aebeeeb628e4 (diff)
Fix unwanted sign extension in lzma decompressor
First extend the uint8_t to size_t, then do the arithmetic, otherwise there is an addtional implicit conversion to int, possibly resulting in unwanted sign extension. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r--lib/sqfs/comp/lzma.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/sqfs/comp/lzma.c b/lib/sqfs/comp/lzma.c
index 0238df0..002376f 100644
--- a/lib/sqfs/comp/lzma.c
+++ b/lib/sqfs/comp/lzma.c
@@ -98,10 +98,10 @@ static sqfs_s32 lzma_uncomp_block(sqfs_compressor_t *base, const sqfs_u8 *in,
if (size < sizeof(lzma_header))
return SQFS_ERROR_CORRUPTED;
- hdrsize = in[LZMA_SIZE_OFFSET] |
- (in[LZMA_SIZE_OFFSET + 1] << 8) |
- (in[LZMA_SIZE_OFFSET + 2] << 16) |
- (in[LZMA_SIZE_OFFSET + 3] << 24);
+ hdrsize = (size_t)in[LZMA_SIZE_OFFSET] |
+ ((size_t)in[LZMA_SIZE_OFFSET + 1] << 8) |
+ ((size_t)in[LZMA_SIZE_OFFSET + 2] << 16) |
+ ((size_t)in[LZMA_SIZE_OFFSET + 3] << 24);
if (hdrsize > outsize)
return 0;