Skip to content

Commit 1f549b1

Browse files
committed
relates to #1251 - masked byte data for lookahead
1 parent 04bc509 commit 1f549b1

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

pg/src/main/java/org/bouncycastle/openpgp/PGPEncryptedData.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,16 @@ else if (len == 0)
103103
int bufferTail = bytesRead - bytesFromLookahead;
104104
for (int i = bufferTail; i < bytesRead; i++)
105105
{
106-
lookAhead[bufPtr] = readBuffer[i];
106+
lookAhead[bufPtr] = readBuffer[i] & 0xff; // we're not at end of file.
107107
bufPtr = (bufPtr + 1) % lookAhead.length;
108108
}
109109

110110
// Copy head of readBuffer to output
111-
System.arraycopy(readBuffer, 0, b, off + bytesFromLookahead, bufferTail);
112-
111+
if (bufferTail != 0)
112+
{
113+
System.arraycopy(readBuffer, 0, b, off + bytesFromLookahead, bufferTail);
114+
}
115+
113116
return bytesRead;
114117
}
115118

0 commit comments

Comments
 (0)