mse: Check that readUntil doesn't read indefinitely while synchronizing
This commit is contained in:
parent
eb29dcec80
commit
0d5c10ef53
|
@ -2,7 +2,9 @@ package mse
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/rand"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"sync"
|
||||
|
||||
|
@ -102,3 +104,19 @@ func BenchmarkHandshake(b *testing.B) {
|
|||
allHandshakeTests(b)
|
||||
}
|
||||
}
|
||||
|
||||
type trackReader struct {
|
||||
r io.Reader
|
||||
n int64
|
||||
}
|
||||
|
||||
func (me *trackReader) Read(b []byte) (n int, err error) {
|
||||
n, err = me.r.Read(b)
|
||||
me.n += int64(n)
|
||||
return
|
||||
}
|
||||
|
||||
func TestReceiveRandomData(t *testing.T) {
|
||||
tr := trackReader{rand.Reader, 0}
|
||||
ReceiveHandshake(readWriter{&tr, ioutil.Discard}, nil)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue