Skip to content

Commit

Permalink
validate quorum ID
Browse files Browse the repository at this point in the history
  • Loading branch information
ian-shim committed Jun 20, 2024
1 parent c5de108 commit ab28b89
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions disperser/dataapi/subgraph_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,9 @@ func parseOperatorQuorum(operatorQuorum []*subgraph.OperatorQuorum) ([]*Operator
if err != nil {
return nil, err
}
if quorum < 0 || 255 < quorum {
return nil, fmt.Errorf("Given quorum ID %d is not between 0 and 255", quorum)
}
quorumNumbers = append(quorumNumbers, uint8(quorum))
}
parsed[i] = &OperatorQuorum{
Expand Down
3 changes: 3 additions & 0 deletions node/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ func NewConfig(ctx *cli.Context) (*Config, error) {
if err != nil {
return nil, err
}
if val < 0 || 255 < val {
return nil, fmt.Errorf("Given quorum ID %d is not between 0 and 255", val)
}
ids = append(ids, core.QuorumID(val))
}
if len(ids) == 0 {
Expand Down
4 changes: 4 additions & 0 deletions node/plugin/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package plugin

import (
"errors"
"fmt"
"strconv"
"strings"

Expand Down Expand Up @@ -136,6 +137,9 @@ func NewConfig(ctx *cli.Context) (*Config, error) {
if err != nil {
return nil, err
}
if val < 0 || 255 < val {
return nil, fmt.Errorf("Given quorum ID %d is not between 0 and 255", val)
}
ids = append(ids, core.QuorumID(val))
}
if len(ids) == 0 {
Expand Down

0 comments on commit ab28b89

Please sign in to comment.