Skip to content

Commit

Permalink
Fix #13 - TAR does not have enough EOF blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
siegfriedpammer committed Aug 18, 2017
1 parent d2526a8 commit 7ff36ba
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/ICSharpCode.SharpZipLib/Tar/TarOutputStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -390,12 +390,13 @@ public override void Write(byte[] buffer, int offset, int count)

/// <summary>
/// Write an EOF (end of archive) block to the tar archive.
/// An EOF block consists of all zeros.
/// The end of the archive is indicated by two blocks consisting entirely of zero bytes.
/// </summary>
void WriteEofBlock()
{
Array.Clear(blockBuffer, 0, blockBuffer.Length);
buffer.WriteBlock(blockBuffer);
buffer.WriteBlock(blockBuffer);
}

#region Instance Fields
Expand Down
4 changes: 2 additions & 2 deletions test/ICSharpCode.SharpZipLib.Tests/Tar/TarTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void BlockFactorHandling()
Assert.IsNotNull(tarData, "Data written is null");

// Blocks = Header + Data Blocks + Zero block + Record trailer
int usedBlocks = 1 + (factor * FillFactor) + 1;
int usedBlocks = 1 + (factor * FillFactor) + 2;
int totalBlocks = usedBlocks + (factor - 1);
totalBlocks /= factor;
totalBlocks *= factor;
Expand Down Expand Up @@ -146,7 +146,7 @@ public void TrailerContainsNulls()
Assert.IsNotNull(tarData, "Data written is null");

// Blocks = Header + Data Blocks + Zero block + Record trailer
int usedBlocks = 1 + iteration + 1;
int usedBlocks = 1 + iteration + 2;
int totalBlocks = usedBlocks + (TestBlockFactor - 1);
totalBlocks /= TestBlockFactor;
totalBlocks *= TestBlockFactor;
Expand Down

0 comments on commit 7ff36ba

Please sign in to comment.