summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2021-03-06 19:09:29 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2021-03-06 22:08:36 +0100
commit31c30ced2d23bea1d8ddeaca685cfaa7ffb1a75d (patch)
tree446a38056e1aeb52f824fd390a1f2c2849b69dfa
parentacb690df464829f58bc7e29abaab7e07349e8e3a (diff)
Fix: meta reader behaviour if accessing block at location 0
Technically, this should *never* **ever** happen, because a SquashFS file always starts with a super block, which isn't wrapped in a meta data block, so a valid SquashFS file will never have a reason to read from offset 0. However, this does bite us when doing unit tests where the meta reader and writer are used on an otherwise empty file. When trying to read from offset 0, the caching code assumes that we already have that block, since tha block_offset got initialized to 0. This commit changes the initialization to set the current block location to the maximum 64 bit integer, a location we are never going to read from, since it will always be after the limit. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r--lib/sqfs/meta_reader.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/sqfs/meta_reader.c b/lib/sqfs/meta_reader.c
index b16b115..a47c1e8 100644
--- a/lib/sqfs/meta_reader.c
+++ b/lib/sqfs/meta_reader.c
@@ -76,6 +76,7 @@ sqfs_meta_reader_t *sqfs_meta_reader_create(sqfs_file_t *file,
((sqfs_object_t *)m)->copy = meta_reader_copy;
((sqfs_object_t *)m)->destroy = meta_reader_destroy;
+ m->block_offset = 0xFFFFFFFFFFFFFFFFUL;
m->start = start;
m->limit = limit;
m->file = file;