From 88849736b22968d74a5fa9f0654cf29044869739 Mon Sep 17 00:00:00 2001 From: Adam Langley Date: Thu, 10 Mar 2016 14:52:01 -0800 Subject: [PATCH] crypto/tls: better error for oversized handshake messages. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This change improves the error message when encountering a TLS handshake message that is larger than our limit (64KB). Previously the error was just “local error: internal error”. Updates #13401. Change-Id: I86127112045ae33e51079e3bc047dd7386ddc71a Reviewed-on: https://go-review.googlesource.com/20547 Reviewed-by: Brad Fitzpatrick Run-TryBot: Adam Langley TryBot-Result: Gobot Gobot --- src/crypto/tls/conn.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/crypto/tls/conn.go b/src/crypto/tls/conn.go index 89e4c2f74a..42445b94d7 100644 --- a/src/crypto/tls/conn.go +++ b/src/crypto/tls/conn.go @@ -803,7 +803,8 @@ func (c *Conn) readHandshake() (interface{}, error) { data := c.hand.Bytes() n := int(data[1])<<16 | int(data[2])<<8 | int(data[3]) if n > maxHandshake { - return nil, c.in.setErrorLocked(c.sendAlert(alertInternalError)) + c.sendAlertLocked(alertInternalError) + return nil, c.in.setErrorLocked(fmt.Errorf("tls: handshake message of length %d bytes exceeds maximum of %d bytes", n, maxHandshake)) } for c.hand.Len() < 4+n { if err := c.in.err; err != nil { -- 2.48.1