Skip to content

Commit

Permalink
Fix a bug with the implementation of tarlib where it would attempt to…
Browse files Browse the repository at this point in the history
… create an MD5 of the contents of the tar file as well as the filename if the overall file size was less than 512 bytes. the TAR specification says the minimum size of a TAR file has to be at least 1024 bytes, or two TBLOCKS in length.

This at least should address the problem we know about.  We need to continue to investigate the migration to libArchive.
  • Loading branch information
romw committed Jan 8, 2022
1 parent 2395ff3 commit cea4fb7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion MainScan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ int32_t __cdecl wmain(int32_t argc, wchar_t* argv[]) {
wprintf(L"\nScan Summary:\n");
wprintf(L"\tScan Date:\t\t\t %s\n", FormatLocalTime(repSummary.scanStart).c_str());
wprintf(L"\tScan Duration:\t\t\t %lld Seconds\n", repSummary.scanEnd - repSummary.scanStart);
wprintf(L"\tScan Error Count:\t\t\t %I64d\n", repSummary.scanErrorCount);
wprintf(L"\tScan Error Count:\t\t %I64d\n", repSummary.scanErrorCount);
wprintf(L"\tScan Status:\t\t\t %s\n", repSummary.scanStatus.c_str());
wprintf(L"\tFiles Scanned:\t\t\t %lld\n", repSummary.scannedFiles);
wprintf(L"\tDirectories Scanned:\t\t %lld\n", repSummary.scannedDirectories);
Expand Down
2 changes: 2 additions & 0 deletions Scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,8 @@ int32_t ScanFileCompressedGZIPTarball(bool console, bool verbose, std::wstring f

if (UncompressGZIPContentsToFile(gzf, tmpFilename)) {
ScanFileTarball(console, verbose, file, tmpFilename);

gzclose(gzf);
DeleteFile(tmpFilename);
}
}
Expand Down
6 changes: 3 additions & 3 deletions tarlib/tarlib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,10 @@ namespace tarlib
_headersize += bytesRead;
_nextentrypos += (streamoff)bytesRead;

// if we don't have 512 bytes this should be the MD5 hash and filename
if(bytesRead < tarChunkSize)
// if we don't have 2 chunks, we don't have a valid tar file
if(bytesRead < tarChunkSize*2)
{
return tarEntry::makeMD5(&block[0], (size_t)bytesRead);
return tarEntry();
}

if(memcmp(block, zerorecord, tarChunkSize) == 0)
Expand Down

0 comments on commit cea4fb7

Please sign in to comment.