]> Cypherpunks repositories - gostls13.git/commitdiff
crypto/tls: use io.ReadFull in conn_test.go
authorJoe Tsai <joetsai@digital-static.net>
Fri, 24 Feb 2017 01:41:31 +0000 (17:41 -0800)
committerJoe Tsai <thebrokentoaster@gmail.com>
Fri, 24 Feb 2017 02:36:10 +0000 (02:36 +0000)
An io.Reader does not guarantee that it will read in the entire buffer.
To ensure that property, io.ReadFull should be used instead.

Change-Id: I0b863135ab9abc40e813f9dac07bfb2a76199950
Reviewed-on: https://go-review.googlesource.com/37403
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/crypto/tls/conn_test.go

index e58077e6927884d3b524e7643f6bd6b3e34bd984..e27c5414b22bdf7e65cb8571fef3b24367870915 100644 (file)
@@ -138,7 +138,7 @@ func runDynamicRecordSizingTest(t *testing.T, config *Config) {
 
                tlsConn := Client(clientConn, config)
                if err := tlsConn.Handshake(); err != nil {
-                       t.Errorf("Error from client handshake: %s", err)
+                       t.Errorf("Error from client handshake: %v", err)
                        return
                }
 
@@ -147,12 +147,12 @@ func runDynamicRecordSizingTest(t *testing.T, config *Config) {
                var recordSizes []int
 
                for {
-                       n, err := clientConn.Read(recordHeader[:])
+                       n, err := io.ReadFull(clientConn, recordHeader[:])
                        if err == io.EOF {
                                break
                        }
                        if err != nil || n != len(recordHeader) {
-                               t.Errorf("Error from client read: %s", err)
+                               t.Errorf("io.ReadFull = %d, %v", n, err)
                                return
                        }
 
@@ -161,9 +161,9 @@ func runDynamicRecordSizingTest(t *testing.T, config *Config) {
                                record = make([]byte, length)
                        }
 
-                       n, err = clientConn.Read(record[:length])
+                       n, err = io.ReadFull(clientConn, record[:length])
                        if err != nil || n != length {
-                               t.Errorf("Error from client read: %s", err)
+                               t.Errorf("io.ReadFull = %d, %v", n, err)
                                return
                        }