Skip to content

readLengthEncodedString should limit the capacity on returned byte slice. #765

Closed
@renthraysk

Description

@renthraysk

If the return byte slice is scanned into a sql.RawBytes, seems like an append() could overwrite other values.

mysql/utils.go

Lines 529 to 543 in 02eb68a

func readLengthEncodedString(b []byte) ([]byte, bool, int, error) {
// Get length
num, isNull, n := readLengthEncodedInteger(b)
if num < 1 {
return b[n:n], isNull, n, nil
}
n += int(num)
// Check data length
if len(b) >= n {
return b[n-int(num) : n], false, n, nil
}
return nil, false, n, io.EOF
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions