Skip to content

Commit 2ef1706

Browse files
committed
Fix LongNames failing for names specifically 512n+1 chars long: we're allocating an extra char which is written NULL for whatever reason, but the writeout code were forgetting to actually write it if it were the only char to fall out of the write buffer of 512 bytes.
1 parent 341466b commit 2ef1706

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

ICSharpCode.SharpZipLib/Tar/TarOutputStream.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,9 @@ public void PutNextEntry(TarEntry entry)
238238

239239
int nameCharIndex = 0;
240240

241-
while (nameCharIndex < entry.TarHeader.Name.Length) {
241+
while (nameCharIndex < entry.TarHeader.Name.Length + 1 /* we've allocated one for the null char, now we must make sure it gets written out */) {
242242
Array.Clear(blockBuffer, 0, blockBuffer.Length);
243-
TarHeader.GetAsciiBytes(entry.TarHeader.Name, nameCharIndex, this.blockBuffer, 0, TarBuffer.BlockSize);
243+
TarHeader.GetAsciiBytes(entry.TarHeader.Name, nameCharIndex, this.blockBuffer, 0, TarBuffer.BlockSize); // This func handles OK the extra char out of string length
244244
nameCharIndex += TarBuffer.BlockSize;
245245
buffer.WriteBlock(blockBuffer);
246246
}

0 commit comments

Comments
 (0)