summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2018-03-09 15:15:27 +0100
committerJulian Andres Klode <julian.klode@canonical.com>2018-04-13 23:15:06 +0200
commit7cf73b7a1e4f127098cae5b8593cd1d0c675e4a4 (patch)
treeabd0c6bfcbef81f4f3409f666d4c3ff93ebc4559 /apt-pkg/contrib
parent9dfbfb24350b1d6b2f48ce66df8873c072f34a06 (diff)
zstd: Implement support for multi-frame files
This implements support for multi frame files while keeping error checking for unexpected EOF working correctly. Files with multiple frames are generated by pzstd, for example.
Diffstat (limited to 'apt-pkg/contrib')
-rw-r--r--apt-pkg/contrib/fileutl.cc16
1 files changed, 12 insertions, 4 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index 5acf40221..85d7b36c7 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -1764,7 +1764,7 @@ class APT_HIDDEN ZstdFileFdPrivate : public FileFdPrivate
virtual ssize_t InternalUnbufferedRead(void *const To, unsigned long long const Size) APT_OVERRIDE
{
/* Keep reading as long as the compressor still wants to read */
- while (next_to_load)
+ while (true)
{
// Fill compressed buffer;
if (zstd_buffer.empty())
@@ -1776,9 +1776,12 @@ class APT_HIDDEN ZstdFileFdPrivate : public FileFdPrivate
return -1;
zstd_buffer.bufferend += read;
- /* Expected EOF */
if (read == 0)
{
+ /* Expected EOF */
+ if (next_to_load == 0)
+ return 0;
+
res = -1;
return filefd->FileFdError("ZSTD: %s %s",
filefd->FileName.c_str(),
@@ -1798,11 +1801,16 @@ class APT_HIDDEN ZstdFileFdPrivate : public FileFdPrivate
.pos = 0,
};
- res = ZSTD_decompressStream(dctx, &out, &in);
+ next_to_load = res = ZSTD_decompressStream(dctx, &out, &in);
+
+ if (res == 0)
+ {
+ res = ZSTD_initDStream(dctx);
+ }
+
if (ZSTD_isError(res))
return -1;
- next_to_load = res;
zstd_buffer.bufferstart += in.pos;
if (out.pos != 0)