Skip to content

Commit

Permalink
8264948: Check for TLS extensions total length
Browse files Browse the repository at this point in the history
Reviewed-by: jnimeh
  • Loading branch information
XueleiFan committed Apr 10, 2021
1 parent 42f4d70 commit 5784f6b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/java.base/share/classes/sun/security/ssl/SSLExtensions.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,26 @@ final class SSLExtensions {
ByteBuffer m, SSLExtension[] extensions) throws IOException {
this.handshakeMessage = hm;

if (m.remaining() < 2) {
throw hm.handshakeContext.conContext.fatal(
Alert.DECODE_ERROR,
"Incorrect extensions: no length field");
}

int len = Record.getInt16(m);
if (len > m.remaining()) {
throw hm.handshakeContext.conContext.fatal(
Alert.DECODE_ERROR,
"Insufficient extensions data");
}

encodedLength = len + 2; // 2: the length of the extensions.
while (len > 0) {
int extId = Record.getInt16(m);
int extLen = Record.getInt16(m);
if (extLen > m.remaining()) {
throw hm.handshakeContext.conContext.fatal(
Alert.ILLEGAL_PARAMETER,
Alert.DECODE_ERROR,
"Error parsing extension (" + extId +
"): no sufficient data");
}
Expand Down

1 comment on commit 5784f6b

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.