diff options
author | Lennart Poettering <lennart@poettering.net> | 2021-01-28 18:16:01 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2021-01-29 16:40:20 +0100 |
commit | 9f0b5640bd316cc23234370abd3a8b2db6e709dd (patch) | |
tree | 7f624e1ffd5e75de4465e8fb16d29e874d790a3b | |
parent | 0dfb650387c2ca578b25c7239995141528236b99 (diff) | |
download | systemd-9f0b5640bd316cc23234370abd3a8b2db6e709dd.tar.gz |
import: don't invoke compress callbacks with empty data
It's pointless if no data was generated. (This happens if an empty file
is compressed)
-rw-r--r-- | src/import/import-compress.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/import/import-compress.c b/src/import/import-compress.c index b89ffb1b2a..c016587e14 100644 --- a/src/import/import-compress.c +++ b/src/import/import-compress.c @@ -125,9 +125,11 @@ int import_uncompress(ImportCompress *c, const void *data, size_t size, ImportCo if (!IN_SET(lzr, LZMA_OK, LZMA_STREAM_END)) return -EIO; - r = callback(buffer, sizeof(buffer) - c->xz.avail_out, userdata); - if (r < 0) - return r; + if (c->xz.avail_out < sizeof(buffer)) { + r = callback(buffer, sizeof(buffer) - c->xz.avail_out, userdata); + if (r < 0) + return r; + } } break; @@ -146,9 +148,11 @@ int import_uncompress(ImportCompress *c, const void *data, size_t size, ImportCo if (!IN_SET(r, Z_OK, Z_STREAM_END)) return -EIO; - r = callback(buffer, sizeof(buffer) - c->gzip.avail_out, userdata); - if (r < 0) - return r; + if (c->gzip.avail_out < sizeof(buffer)) { + r = callback(buffer, sizeof(buffer) - c->gzip.avail_out, userdata); + if (r < 0) + return r; + } } break; @@ -168,9 +172,11 @@ int import_uncompress(ImportCompress *c, const void *data, size_t size, ImportCo if (!IN_SET(r, BZ_OK, BZ_STREAM_END)) return -EIO; - r = callback(buffer, sizeof(buffer) - c->bzip2.avail_out, userdata); - if (r < 0) - return r; + if (c->bzip2.avail_out < sizeof(buffer)) { + r = callback(buffer, sizeof(buffer) - c->bzip2.avail_out, userdata); + if (r < 0) + return r; + } } break; |