diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-05-04 15:32:52 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-05-04 22:22:48 +0200 |
commit | 2b975a449c17268f943403176a7609079b7af084 (patch) | |
tree | fee51e2f4b4f424c9a55dc35fb7aad21e3ce6580 /lib/sqfs/meta_reader.c | |
parent | 6f7ee71165b30272a4f18bca361c324c7671680c (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/meta_reader.c')
-rw-r--r-- | lib/sqfs/meta_reader.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/sqfs/meta_reader.c b/lib/sqfs/meta_reader.c index 8cd7c8f..1a70238 100644 --- a/lib/sqfs/meta_reader.c +++ b/lib/sqfs/meta_reader.c @@ -79,12 +79,18 @@ int meta_reader_seek(meta_reader_t *m, uint64_t block_start, size_t offset) goto fail_trunc; if (compressed) { - ret = m->cmp->do_block(m->cmp, m->data, size); + ret = m->cmp->do_block(m->cmp, m->data, size, + m->scratch, sizeof(m->scratch)); if (ret <= 0) { fputs("error uncompressing meta data block\n", stderr); return -1; } + + memcpy(m->data, m->scratch, ret); + + if ((size_t)ret < sizeof(m->data)) + memset(m->data + ret, 0, sizeof(m->data) - ret); } return 0; |