mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-03 01:41:48 +00:00
rpc, internal: fix CodeQL int conversions warnings
``` Incorrect conversion of an integer with architecture-dependent bit size from to a lower bit size type int32 without an upper bound check. ```
This commit is contained in:
parent
db868f033e
commit
ae36523a61
3 changed files with 33 additions and 0 deletions
20
pkg/rpc/server/util.go
Normal file
20
pkg/rpc/server/util.go
Normal file
|
@ -0,0 +1,20 @@
|
|||
package server
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"math"
|
||||
)
|
||||
|
||||
func checkUint32(i int) error {
|
||||
if i < 0 || i > math.MaxUint32 {
|
||||
return errors.New("value should fit uint32")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func checkInt32(i int) error {
|
||||
if i < math.MinInt32 || i > math.MaxInt32 {
|
||||
return errors.New("value should fit int32")
|
||||
}
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue