Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

connection: fix svacer issue #361

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,7 @@ func (conn *Connection) timeouts() {
}

func read(r io.Reader, lenbuf []byte) (response []byte, err error) {
var length int
var length uint64

if _, err = io.ReadFull(r, lenbuf); err != nil {
return
Expand All @@ -1167,15 +1167,20 @@ func read(r io.Reader, lenbuf []byte) (response []byte, err error) {
err = errors.New("wrong response header")
return
}
length = (int(lenbuf[1]) << 24) +
(int(lenbuf[2]) << 16) +
(int(lenbuf[3]) << 8) +
int(lenbuf[4])
length = (uint64(lenbuf[1]) << 24) +
(uint64(lenbuf[2]) << 16) +
(uint64(lenbuf[3]) << 8) +
uint64(lenbuf[4])

if length == 0 {
switch {
case length == 0:
err = errors.New("response should not be 0 length")
return
case length > math.MaxUint32:
err = errors.New("response is too big")
return
}

response = make([]byte, length)
_, err = io.ReadFull(r, response)

Expand Down
Loading