summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-07-04 19:24:44 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-07-04 19:24:44 +0200
commit8ce28a622dbfbf2d4db3e9805e95e532c8e2dc13 (patch)
tree8188023f70c2142f4654876def41e45483d4b3bf /lib
parent5161ab16583f5e619050d3bead0f49cd47dff66e (diff)
Fix: check block_log range before deriving block size from it
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib')
-rw-r--r--lib/sqfs/read_super.c10
1 files 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);