Skip to content

Commit

Permalink
Fix unsafe direct field access for Int8/Int16 result data (#615)
Browse files Browse the repository at this point in the history
Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
  • Loading branch information
congqixia authored Nov 8, 2023
1 parent 18efb15 commit 94c4107
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
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

0 comments on commit 94c4107

Please sign in to comment.