From 8ce28a622dbfbf2d4db3e9805e95e532c8e2dc13 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Thu, 4 Jul 2019 19:24:44 +0200 Subject: Fix: check block_log range before deriving block size from it Signed-off-by: David Oberhollenzer --- lib/sqfs/read_super.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/sqfs/read_super.c b/lib/sqfs/read_super.c index 3b41fbd..801bf7f 100644 --- a/lib/sqfs/read_super.c +++ b/lib/sqfs/read_super.c @@ -9,8 +9,8 @@ int sqfs_super_read(sqfs_super_t *super, int fd) { + size_t block_size = 0; sqfs_super_t temp; - size_t block_size; ssize_t ret; int i; @@ -69,10 +69,12 @@ int sqfs_super_read(sqfs_super_t *super, int fd) return -1; } - block_size = 1; + if (temp.block_log > 0 && temp.block_log < 32) { + block_size = 1; - for (i = 0; i < temp.block_log; ++i) - block_size <<= 1; + for (i = 0; i < temp.block_log; ++i) + block_size <<= 1; + } if (temp.block_size != block_size) { fputs("Mismatch between block size and block log\n", stderr); -- cgit v1.2.3