]> Cypherpunks repositories - gostls13.git/commitdiff
crypto/tls: don't block on Read of zero bytes
authorBrad Fitzpatrick <bradfitz@golang.org>
Wed, 16 Apr 2014 02:40:00 +0000 (19:40 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 16 Apr 2014 02:40:00 +0000 (19:40 -0700)
Fixes #7775

LGTM=rsc
R=agl, rsc
CC=golang-codereviews
https://golang.org/cl/88340043

src/pkg/crypto/tls/conn.go

index 000b23cbcac169b44a021a3f8fbb0c52287bbedb..550bc7f8fe5bd955a5daedf1296e648bae3fb89e 100644 (file)
@@ -884,6 +884,11 @@ func (c *Conn) Read(b []byte) (n int, err error) {
        if err = c.Handshake(); err != nil {
                return
        }
+       if len(b) == 0 {
+               // Put this after Handshake, in case people were calling
+               // Read(nil) for the side effect of the Handshake.
+               return
+       }
 
        c.in.Lock()
        defer c.in.Unlock()