From a00555b702bb108d750c1d4ac2cc72c1f6c34019 Mon Sep 17 00:00:00 2001 From: Raul Metsma Date: Wed, 8 Nov 2023 09:47:01 +0200 Subject: [PATCH] Fix compatibility with Tar specification IB-7877 Signed-off-by: Raul Metsma --- client/CDoc2.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/client/CDoc2.cpp b/client/CDoc2.cpp index cb891da16..5dbb32d37 100644 --- a/client/CDoc2.cpp +++ b/client/CDoc2.cpp @@ -242,19 +242,23 @@ namespace cdoc20 { return false; } Header eof{}; - return io->write((const char*)&eof, Header::Size) == Header::Size; + return io->write((const char*)&eof, Header::Size) == Header::Size && + io->write((const char*)&eof, Header::Size) == Header::Size; } std::vector files(bool &warning) const { std::vector result; Header h {}; + auto readHeader = [&h, this] { return io->read((char*)&h, Header::Size) == Header::Size; }; while(io->bytesAvailable() > 0) { - if(io->read((char*)&h, Header::Size) != Header::Size) + if(!readHeader()) return {}; if(h.isNull()) { + if(!readHeader() && !h.isNull()) + return {}; warning = io->bytesAvailable() > 0; return result; } @@ -270,7 +274,7 @@ namespace cdoc20 { if(paxData.size() != f.size) return {}; io->skip(padding(f.size)); - if(io->read((char*)&h, Header::Size) != Header::Size || h.isNull() || !h.verify()) + if(!readHeader() || h.isNull() || !h.verify()) return {}; f.size = fromOctal(h.size); for(const QByteArray &data: paxData.split('\n'))