From 029a8db2701afb0653c6e789c878bb768ceb87e1 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Fri, 23 Aug 2019 12:10:16 +0200 Subject: Do bounds checking in metadata reader In all cases where metadata blocks are read, we can roughly (in some cases even preciesly) say in what range those metadata blocks will be, so it makes sense to throw an error if an attempt is made to wander outside this range. Furthermore, when reading from an uncompressed block, it is more reasonable to check against the actual block bounds than to padd it with 0 bytes. Signed-off-by: David Oberhollenzer --- lib/sqfs/read_table.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/sqfs/read_table.c') diff --git a/lib/sqfs/read_table.c b/lib/sqfs/read_table.c index 12e06b4..6efd401 100644 --- a/lib/sqfs/read_table.c +++ b/lib/sqfs/read_table.c @@ -15,7 +15,8 @@ #include void *sqfs_read_table(int fd, compressor_t *cmp, size_t table_size, - uint64_t location) + uint64_t location, uint64_t lower_limit, + uint64_t upper_limit) { size_t diff, block_count, list_size, blk_idx = 0; uint64_t start, *locations; @@ -48,7 +49,7 @@ void *sqfs_read_table(int fd, compressor_t *cmp, size_t table_size, } /* Read the actual data */ - m = meta_reader_create(fd, cmp); + m = meta_reader_create(fd, cmp, lower_limit, upper_limit); if (m == NULL) goto fail_idx; -- cgit v1.2.3