Skip to content

Commit

Permalink
Fix compatibility with Tar specification
Browse files Browse the repository at this point in the history
IB-7877

Signed-off-by: Raul Metsma <[email protected]>
  • Loading branch information
metsma committed Nov 8, 2023
1 parent d5bbd75 commit a00555b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions client/CDoc2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CDoc::File> files(bool &warning) const
{
std::vector<CDoc::File> 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;
}
Expand All @@ -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'))
Expand Down

0 comments on commit a00555b

Please sign in to comment.