mirror of
https://github.com/prometheus/prometheus.git
synced 2025-08-06 06:07:11 +02:00
Merge pull request #16754 from simonpasquier/fix-promql-panic
fix: prevent invalid array access in aggregate expression
This commit is contained in:
commit
8f75da3fd6
@ -451,6 +451,11 @@ func (p *parser) newAggregateExpr(op Item, modifier, args Node) (ret *AggregateE
|
||||
ret = modifier.(*AggregateExpr)
|
||||
arguments := args.(Expressions)
|
||||
|
||||
if len(p.closingParens) == 0 {
|
||||
// Prevents invalid array accesses.
|
||||
// The error is already captured by the parser.
|
||||
return
|
||||
}
|
||||
ret.PosRange = posrange.PositionRange{
|
||||
Start: op.Pos,
|
||||
End: p.closingParens[0],
|
||||
|
@ -4540,6 +4540,11 @@ var testExpr = []struct {
|
||||
PosRange: posrange.PositionRange{Start: 0, End: 20},
|
||||
},
|
||||
},
|
||||
{
|
||||
input: "sum(rate(",
|
||||
fail: true,
|
||||
errMsg: "unclosed left parenthesis",
|
||||
},
|
||||
}
|
||||
|
||||
func makeInt64Pointer(val int64) *int64 {
|
||||
|
Loading…
Reference in New Issue
Block a user