Skip to content

Commit c54c7fd

Browse files
committed
Partial length encoding: Enforce minimum length of the first chunk
1 parent f1a299b commit c54c7fd

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

pg/src/main/java/org/bouncycastle/bcpg/BCPGInputStream.java

+4
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,10 @@ public Packet readPacket()
205205
boolean[] flags = new boolean[3];
206206
bodyLen = StreamUtil.readBodyLen(this, flags);
207207
partial = flags[StreamUtil.flag_partial];
208+
if (partial && bodyLen < 512)
209+
{
210+
throw new IOException("First chunk of partial body MUST have a length of at least 512 octets.");
211+
}
208212
}
209213
else
210214
{

0 commit comments

Comments
 (0)