diff --git a/ct/serialization.go b/ct/serialization.go index e383ea5..33d5ea9 100644 --- a/ct/serialization.go +++ b/ct/serialization.go @@ -80,13 +80,12 @@ func readVarBytes(r io.Reader, numLenBytes int) ([]byte, error) { return nil, err } data := make([]byte, l) - n, err := r.Read(data) - if err != nil { + if n, err := io.ReadFull(r, data); err != nil { + if err == io.EOF || err == io.ErrUnexpectedEOF { + return nil, fmt.Errorf("short read: expected %d but got %d", l, n) + } return nil, err } - if n != int(l) { - return nil, fmt.Errorf("short read: expected %d but got %d", l, n) - } return data, nil }