summaryrefslogtreecommitdiff
path: root/lib/sqfs/meta_writer.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/meta_writer.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/meta_writer.c')
-rw-r--r--lib/sqfs/meta_writer.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/sqfs/meta_writer.c b/lib/sqfs/meta_writer.c
index 95092d5..77ceeb9 100644
--- a/lib/sqfs/meta_writer.c
+++ b/lib/sqfs/meta_writer.c
@@ -30,23 +30,27 @@ void meta_writer_destroy(meta_writer_t *m)
int meta_writer_flush(meta_writer_t *m)
{
ssize_t ret, count;
+ void *ptr;
if (m->offset == 0)
return 0;
- ret = m->cmp->do_block(m->cmp, m->data + 2, m->offset);
+ ret = m->cmp->do_block(m->cmp, m->data + 2, m->offset,
+ m->scratch + 2, sizeof(m->scratch) - 2);
if (ret < 0)
return -1;
if (ret > 0) {
- ((uint16_t *)m->data)[0] = htole16(ret);
+ ((uint16_t *)m->scratch)[0] = htole16(ret);
count = ret + 2;
+ ptr = m->scratch;
} else {
((uint16_t *)m->data)[0] = htole16(m->offset | 0x8000);
count = m->offset + 2;
+ ptr = m->data;
}
- ret = write_retry(m->outfd, m->data, count);
+ ret = write_retry(m->outfd, ptr, count);
if (ret < 0) {
perror("writing meta data");