aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/protocol/packp/srvresp.go
diff options
context:
space:
mode:
authorPaulo Gomes <pjbgf@linux.com>2023-10-07 18:44:31 +0100
committerPaulo Gomes <pjbgf@linux.com>2023-10-07 18:44:31 +0100
commit1d26511c717ea334a16499a018d2b877b557be79 (patch)
treefbf1be6db06f715045a31cf0d52cb82c7405ad66 /plumbing/protocol/packp/srvresp.go
parent19fe126d8889134e6224717a756745eed9985e22 (diff)
downloadgo-git-1d26511c717ea334a16499a018d2b877b557be79.tar.gz
plumbing: protocol/packp, Add validation for decodeLine
Signed-off-by: Paulo Gomes <pjbgf@linux.com>
Diffstat (limited to 'plumbing/protocol/packp/srvresp.go')
-rw-r--r--plumbing/protocol/packp/srvresp.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/plumbing/protocol/packp/srvresp.go b/plumbing/protocol/packp/srvresp.go
index 8cd0a72..a9ddb53 100644
--- a/plumbing/protocol/packp/srvresp.go
+++ b/plumbing/protocol/packp/srvresp.go
@@ -101,12 +101,14 @@ func (r *ServerResponse) decodeLine(line []byte) error {
return fmt.Errorf("unexpected flush")
}
- if bytes.Equal(line[0:3], ack) {
- return r.decodeACKLine(line)
- }
+ if len(line) >= 3 {
+ if bytes.Equal(line[0:3], ack) {
+ return r.decodeACKLine(line)
+ }
- if bytes.Equal(line[0:3], nak) {
- return nil
+ if bytes.Equal(line[0:3], nak) {
+ return nil
+ }
}
return fmt.Errorf("unexpected content %q", string(line))