Skip to content

Commit 7ff36ba

Browse files
Fix #13 - TAR does not have enough EOF blocks
1 parent d2526a8 commit 7ff36ba

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/ICSharpCode.SharpZipLib/Tar/TarOutputStream.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,12 +390,13 @@ public override void Write(byte[] buffer, int offset, int count)
390390

391391
/// <summary>
392392
/// Write an EOF (end of archive) block to the tar archive.
393-
/// An EOF block consists of all zeros.
393+
/// The end of the archive is indicated by two blocks consisting entirely of zero bytes.
394394
/// </summary>
395395
void WriteEofBlock()
396396
{
397397
Array.Clear(blockBuffer, 0, blockBuffer.Length);
398398
buffer.WriteBlock(blockBuffer);
399+
buffer.WriteBlock(blockBuffer);
399400
}
400401

401402
#region Instance Fields

test/ICSharpCode.SharpZipLib.Tests/Tar/TarTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public void BlockFactorHandling()
8282
Assert.IsNotNull(tarData, "Data written is null");
8383

8484
// Blocks = Header + Data Blocks + Zero block + Record trailer
85-
int usedBlocks = 1 + (factor * FillFactor) + 1;
85+
int usedBlocks = 1 + (factor * FillFactor) + 2;
8686
int totalBlocks = usedBlocks + (factor - 1);
8787
totalBlocks /= factor;
8888
totalBlocks *= factor;
@@ -146,7 +146,7 @@ public void TrailerContainsNulls()
146146
Assert.IsNotNull(tarData, "Data written is null");
147147

148148
// Blocks = Header + Data Blocks + Zero block + Record trailer
149-
int usedBlocks = 1 + iteration + 1;
149+
int usedBlocks = 1 + iteration + 2;
150150
int totalBlocks = usedBlocks + (TestBlockFactor - 1);
151151
totalBlocks /= TestBlockFactor;
152152
totalBlocks *= TestBlockFactor;

0 commit comments

Comments
 (0)