Skip to content

Commit

Permalink
Fix uint32 argument parsing type mismatch (#3969)
Browse files Browse the repository at this point in the history
Atoi parses ints which do not match the range of the expected arguments (uint32)
  • Loading branch information
2opremio authored Sep 29, 2021
1 parent 0a091b9 commit bad46d1
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions services/horizon/cmd/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,9 @@ var dbReingestRangeCmd = &cobra.Command{

argsUInt32 := make([]uint32, 2)
for i, arg := range args {
if seq, err := strconv.Atoi(arg); err != nil {
if seq, err := strconv.ParseUint(arg, 10, 32); err != nil {
cmd.Usage()
return fmt.Errorf(`Invalid sequence number "%s"`, arg)
} else if seq < 0 {
return fmt.Errorf("sequence number %s cannot be negative", arg)
} else {
argsUInt32[i] = uint32(seq)
}
Expand Down

0 comments on commit bad46d1

Please sign in to comment.