Permalink
Browse files

Fix #13 - TAR does not have enough EOF blocks

  • Loading branch information...
siegfriedpammer committed Aug 18, 2017
1 parent d2526a8 commit 7ff36ba87498d18cb1e4a01c48a23240ba031c06
@@ -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
@@ -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;
@@ -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;

0 comments on commit 7ff36ba

Please sign in to comment.