From: Adam Langley Date: Thu, 10 Mar 2016 22:52:01 +0000 (-0800) Subject: crypto/tls: better error for oversized handshake messages. X-Git-Tag: go1.7beta1~1380 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=88849736b22968d74a5fa9f0654cf29044869739;p=gostls13.git crypto/tls: better error for oversized handshake messages. 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 --- 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 {