Skip to content

Commit c957965

Browse files
PendingBuffer ToByteArray() to return all bytes
If AlignToByte() (or a procedure similar to that in Flush()) is not done within ToByteArray(), the bits variable may contain up to 15 bits not present in buffer_ which could result in data truncation. I have added AlignToByte() on the assumption that ToByteArray() will only be called when all output to PendingBuffer is complete.
1 parent 8ab0251 commit c957965

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

ICSharpCode.SharpZipLib/Zip/Compression/PendingBuffer.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ public int Flush(byte[] output, int offset, int length)
245245
/// </returns>
246246
public byte[] ToByteArray()
247247
{
248+
AlignToByte();
249+
248250
byte[] result = new byte[end - start];
249251
System.Array.Copy(buffer_, start, result, 0, result.Length);
250252
start = 0;

0 commit comments

Comments
 (0)