Skip to content

Commit b0b43bb

Browse files
committed
ext-info: add upper limit check for compat
This matches what OpenSSH does.
1 parent 09f32b3 commit b0b43bb

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/main/java/com/trilead/ssh2/packets/PacketExtInfo.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ public PacketExtInfo(byte[] payload, int off, int len) throws IOException
5454
// Type has dynamic number of fields
5555
// First int tells us how many pairs to expect
5656
int numExtensions = tr.readUINT32();
57+
if (numExtensions >= 1024) {
58+
throw new IOException("Too many entries in ext info packet");
59+
}
60+
5761
Map<String, String> extNameToValue_ = new HashMap<>(numExtensions);
5862
for (int i = 0; i < numExtensions; i++)
5963
{

0 commit comments

Comments
 (0)