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

Fix unsafe direct field access for Int8/Int16 result data #615

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
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
10 changes: 5 additions & 5 deletions client/data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -870,14 +870,14 @@ func TestGrpcCalcDistanceWithIDs(t *testing.T) {
// this injection returns float distance
dl := 0
if idsLeft != nil {
dl = len(idsLeft.IdArray.GetIntId().Data)
dl = len(idsLeft.IdArray.GetIntId().GetData())
}
if valuesLeft != nil {
dl = len(valuesLeft.GetFloatVector().GetData()) / int(valuesLeft.Dim)
}
dr := 0
if idsRight != nil {
dr = len(idsRight.IdArray.GetIntId().Data)
dr = len(idsRight.IdArray.GetIntId().GetData())
}
if valuesRight != nil {
dr = len(valuesRight.GetFloatVector().GetData()) / int(valuesRight.Dim)
Expand Down Expand Up @@ -935,14 +935,14 @@ func TestGrpcCalcDistanceWithIDs(t *testing.T) {
// this injection returns float distance
dl := 0
if idsLeft != nil {
dl = len(idsLeft.IdArray.GetIntId().Data)
dl = len(idsLeft.IdArray.GetIntId().GetData())
}
if valuesLeft != nil {
dl = len(valuesLeft.GetFloatVector().GetData()) / int(valuesLeft.Dim)
}
dr := 0
if idsRight != nil {
dr = len(idsRight.IdArray.GetIntId().Data)
dr = len(idsRight.IdArray.GetIntId().GetData())
}
if valuesRight != nil {
dr = len(valuesRight.GetFloatVector().GetData()) / int(valuesRight.Dim)
Expand Down Expand Up @@ -1004,7 +1004,7 @@ func TestGrpcCalcDistanceWithIDs(t *testing.T) {
assert.NotNil(t, idsRight.IdArray.GetStrId())

// this injection returns float distance
dl := len(idsLeft.IdArray.GetStrId().Data)
dl := len(idsLeft.IdArray.GetStrId().GetData())

resp.Array = &milvuspb.CalcDistanceResults_FloatDist{
FloatDist: &schemapb.FloatArray{
Expand Down
4 changes: 2 additions & 2 deletions entity/columns.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ func parseArrayData(fieldName string, array *schema.ArrayArray) (Column, error)
case schema.DataType_Int8:
var data [][]int8
for _, fd := range fieldDataList {
raw := fd.GetIntData().Data
raw := fd.GetIntData().GetData()
row := make([]int8, 0, len(raw))
for _, item := range raw {
row = append(row, int8(item))
Expand All @@ -331,7 +331,7 @@ func parseArrayData(fieldName string, array *schema.ArrayArray) (Column, error)
case schema.DataType_Int16:
var data [][]int16
for _, fd := range fieldDataList {
raw := fd.GetIntData().Data
raw := fd.GetIntData().GetData()
row := make([]int16, 0, len(raw))
for _, item := range raw {
row = append(row, int16(item))
Expand Down
Loading