Skip to content

Commit

Permalink
btcjson: check if both begin and end are numbers in UnmarshalJSON
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoerg authored Aug 23, 2024
1 parent 029e5a3 commit 1a1dd2a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions btcjson/walletsvrcmds.go
Original file line number Diff line number Diff line change
Expand Up @@ -903,9 +903,14 @@ func (r *DescriptorRange) UnmarshalJSON(data []byte) error {
if len(v) != 2 {
return fmt.Errorf("expected [begin,end] integer range, got: %v", unmarshalled)
}
begin, ok1 := v[0].(float64)
end, ok2 := v[1].(float64)
if !ok1 || !ok2 {
return fmt.Errorf("expected both begin and end to be numbers, got: %v", v)
}
r.Value = []int{
int(v[0].(float64)),
int(v[1].(float64)),
int(begin),
int(end),
}
default:
return fmt.Errorf("invalid descriptor range value: %v", unmarshalled)
Expand Down

0 comments on commit 1a1dd2a

Please sign in to comment.