Skip to content

Commit f58ce0b

Browse files
committed
Fixed a SNI Parser bug if the server decided to send an empty SNI extension message
1 parent 4840dea commit f58ce0b

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

TLS-Core/src/main/java/de/rub/nds/tlsattacker/core/protocol/parser/extension/ServerNameIndicationExtensionParser.java

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,24 @@ public ServerNameIndicationExtensionParser(int startposition, byte[] array) {
2626

2727
@Override
2828
public void parseExtensionMessageContent(ServerNameIndicationExtensionMessage msg) {
29-
parseServerNameListLength(msg);
30-
parseServerNameListBytes(msg);
31-
int position = 0;
32-
pairList = new LinkedList<>();
33-
while (position < msg.getServerNameListLength().getValue()) {
34-
ServerNamePairParser parser = new ServerNamePairParser(position, msg.getServerNameListBytes().getValue());
35-
pairList.add(parser.parse());
36-
if (position == parser.getPointer()) {
37-
throw new ParserException("Ran into infinite Loop while parsing ServerNamePair");
29+
if (msg.getExtensionLength().getValue() > 0) {
30+
parseServerNameListLength(msg);
31+
parseServerNameListBytes(msg);
32+
int position = 0;
33+
pairList = new LinkedList<>();
34+
while (position < msg.getServerNameListLength().getValue()) {
35+
ServerNamePairParser parser = new ServerNamePairParser(position, msg.getServerNameListBytes()
36+
.getValue());
37+
pairList.add(parser.parse());
38+
if (position == parser.getPointer()) {
39+
throw new ParserException("Ran into infinite Loop while parsing ServerNamePair");
40+
}
41+
position = parser.getPointer();
3842
}
39-
position = parser.getPointer();
43+
parseServerNameList(msg);
44+
} else {
45+
LOGGER.debug("Received empty SNI Extension");
4046
}
41-
parseServerNameList(msg);
4247
}
4348

4449
@Override

0 commit comments

Comments
 (0)