Skip to content

Commit

Permalink
Fix out-of-bound array access crash in select processing (minio#6594)
Browse files Browse the repository at this point in the history
Fix test case.
  • Loading branch information
donatello authored and kannappanr committed Oct 9, 2018
1 parent cbc5d78 commit 16a100b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions pkg/s3select/select.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,9 @@ func aggregationFunctions(counter int, filtrCount int, myAggVals []float64, colu
// If column names are provided as an index it'll use this if statement instead of the else/
var convAggFloat float64
if representsInt(storeReqCols[i]) {
myIndex, _ := strconv.Atoi(storeReqCols[i])
convAggFloat, _ = strconv.ParseFloat(record[myIndex], 64)
colIndex, _ := strconv.Atoi(storeReqCols[i])
// colIndex is 1-based
convAggFloat, _ = strconv.ParseFloat(record[colIndex-1], 64)

} else {
// case that the columns are in the form of named columns rather than indices.
Expand Down
2 changes: 1 addition & 1 deletion pkg/s3select/select_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ func TestMyAggregationFunc(t *testing.T) {
{1, 1, []float64{10}, columnsMap, []string{"Col1"}, []string{"avg"}, []string{"1", "2"}, nil, 5.500},
{10, 5, []float64{0.000}, columnsMap, []string{"Col1"}, []string{"random"}, []string{"1", "2"}, ErrParseNonUnaryAgregateFunctionCall, 0},
{0, 5, []float64{0}, columnsMap, []string{"0"}, []string{"count"}, []string{"1", "2"}, nil, 1},
{10, 5, []float64{10}, columnsMap, []string{"1"}, []string{"min"}, []string{"1", "12"}, nil, 10},
{10, 5, []float64{10}, columnsMap, []string{"1"}, []string{"min"}, []string{"1", "12"}, nil, 1},
}
for _, table := range tables {
err := aggregationFunctions(table.counter, table.filtrCount, table.myAggVals, table.columnsMap, table.storeReqCols, table.storeFunctions, table.record)
Expand Down

0 comments on commit 16a100b

Please sign in to comment.