mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8182621: JSSE should reject empty TLS plaintexts
Reviewed-by: xuelei
This commit is contained in:
parent
137513025d
commit
39398075b7
4 changed files with 648 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -263,6 +263,12 @@ final class SSLEngineInputRecord extends InputRecord implements SSLRecord {
|
|||
// parse handshake messages
|
||||
//
|
||||
if (contentType == ContentType.HANDSHAKE.id) {
|
||||
if (contentLen == 0) {
|
||||
// From RFC 8446: "Implementations MUST NOT send zero-length fragments
|
||||
// of Handshake types, even if those fragments contain padding."
|
||||
throw new SSLProtocolException("Handshake packets must not be zero-length");
|
||||
}
|
||||
|
||||
ByteBuffer handshakeFrag = fragment;
|
||||
if ((handshakeBuffer != null) &&
|
||||
(handshakeBuffer.remaining() != 0)) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, Azul Systems, Inc. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
|
@ -284,6 +284,12 @@ final class SSLSocketInputRecord extends InputRecord implements SSLRecord {
|
|||
//
|
||||
if (contentType == ContentType.HANDSHAKE.id) {
|
||||
ByteBuffer handshakeFrag = fragment;
|
||||
if (contentLen == 0) {
|
||||
// From RFC 8446: "Implementations MUST NOT send zero-length fragments
|
||||
// of Handshake types, even if those fragments contain padding."
|
||||
throw new SSLProtocolException("Handshake fragments must not be zero length.");
|
||||
}
|
||||
|
||||
if ((handshakeBuffer != null) &&
|
||||
(handshakeBuffer.remaining() != 0)) {
|
||||
ByteBuffer bb = ByteBuffer.wrap(new byte[
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue