This repository was archived by the owner on Sep 11, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -80,10 +80,11 @@ func (s *Scanner) Bytes() []byte {
80
80
// pkt-len and substracting the pkt-len size.
81
81
func (s * Scanner ) readPayloadLen () (int , error ) {
82
82
if _ , err := io .ReadFull (s .r , s .len [:]); err != nil {
83
- if err == io .EOF {
84
- return 0 , err
83
+ if err == io .ErrUnexpectedEOF {
84
+ return 0 , ErrInvalidPktLen
85
85
}
86
- return 0 , ErrInvalidPktLen
86
+
87
+ return 0 , err
87
88
}
88
89
89
90
n , err := hexDecode (s .len )
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package pktline_test
2
2
3
3
import (
4
4
"bytes"
5
+ "errors"
5
6
"fmt"
6
7
"io"
7
8
"strings"
@@ -145,6 +146,16 @@ func (s *SuiteScanner) TestEOF(c *C) {
145
146
c .Assert (sc .Err (), IsNil )
146
147
}
147
148
149
+ type mockReader struct {}
150
+
151
+ func (r * mockReader ) Read ([]byte ) (int , error ) { return 0 , errors .New ("foo" ) }
152
+
153
+ func (s * SuiteScanner ) TestInternalReadError (c * C ) {
154
+ sc := pktline .NewScanner (& mockReader {})
155
+ c .Assert (sc .Scan (), Equals , false )
156
+ c .Assert (sc .Err (), ErrorMatches , "foo" )
157
+ }
158
+
148
159
// A section are several non flush-pkt lines followed by a flush-pkt, which
149
160
// how the git protocol sends long messages.
150
161
func (s * SuiteScanner ) TestReadSomeSections (c * C ) {
You can’t perform that action at this time.
0 commit comments