summaryrefslogtreecommitdiff
path: root/lib/sqfs/frag_reader.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-05-04 15:32:52 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-05-04 22:22:48 +0200
commit2b975a449c17268f943403176a7609079b7af084 (patch)
treefee51e2f4b4f424c9a55dc35fb7aad21e3ce6580 /lib/sqfs/frag_reader.c
parent6f7ee71165b30272a4f18bca361c324c7671680c (diff)
Remove compressor internal buffers
Pass in an external destination buffer + size and allow for propper bounds checking (especially when unpacking). Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/frag_reader.c')
-rw-r--r--lib/sqfs/frag_reader.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/sqfs/frag_reader.c b/lib/sqfs/frag_reader.c
index 1906376..74fd292 100644
--- a/lib/sqfs/frag_reader.c
+++ b/lib/sqfs/frag_reader.c
@@ -42,12 +42,15 @@ static int precache_block(frag_reader_t *f, size_t i)
}
if (compressed) {
- ret = f->cmp->do_block(f->cmp, f->buffer, size);
+ ret = f->cmp->do_block(f->cmp, f->buffer, size,
+ f->buffer + f->block_size, f->block_size);
if (ret <= 0) {
fputs("extracting fragment failed\n", stderr);
return -1;
}
+
+ memmove(f->buffer, f->buffer + f->block_size, ret);
}
f->current_index = i;
@@ -73,7 +76,7 @@ frag_reader_t *frag_reader_create(sqfs_super_t *super, int fd,
++blockcount;
/* pre allocate all the stuff */
- f = calloc(1, sizeof(*f) + super->block_size);
+ f = calloc(1, sizeof(*f) + super->block_size * 2);
if (f == NULL)
goto fail_rd;