summaryrefslogtreecommitdiff
path: root/lib/sqfs
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2022-06-01 00:11:32 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2022-06-01 00:13:24 +0200
commitfa7110a9c4bd0ece4be33998b6f9e7d4f528acc7 (patch)
tree42a0d55c1a0f0414baee929bab84eeb48ad01564 /lib/sqfs
parente2786de8c6c82d00b450faecff662d585f932286 (diff)
Fix: libsqfs: do not report out of bounds positions from meta reader
When asking the meta data reader for its current position and we *just* read to the end of a block, report the start of the next block as the current location. Otherwise, trying to *seek* to the resulting position immediately after reporting throws an out-of-bounds error. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs')
-rw-r--r--lib/sqfs/meta_reader.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/sqfs/meta_reader.c b/lib/sqfs/meta_reader.c
index a47c1e8..94da268 100644
--- a/lib/sqfs/meta_reader.c
+++ b/lib/sqfs/meta_reader.c
@@ -147,8 +147,13 @@ int sqfs_meta_reader_seek(sqfs_meta_reader_t *m, sqfs_u64 block_start,
void sqfs_meta_reader_get_position(const sqfs_meta_reader_t *m,
sqfs_u64 *block_start, size_t *offset)
{
- *block_start = m->block_offset;
- *offset = m->offset;
+ if (m->offset == m->data_used) {
+ *block_start = m->next_block;
+ *offset = 0;
+ } else {
+ *block_start = m->block_offset;
+ *offset = m->offset;
+ }
}
int sqfs_meta_reader_read(sqfs_meta_reader_t *m, void *data, size_t size)