mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
Potential fix for code scanning alert no. 9: Incorrect conversion between integer types
Romeo Rosete Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This commit is contained in:
parent
4c939b5196
commit
6e96ff3204
2 changed files with 5 additions and 1 deletions
|
|
@ -336,7 +336,7 @@ func parseExtAddr(spec string) (ip net.IP, port int, ok bool) {
|
|||
return nil, 0, false
|
||||
}
|
||||
port, err = strconv.Atoi(portstr)
|
||||
if err != nil {
|
||||
if err != nil || port < 0 || port > 65535 {
|
||||
return nil, 0, false
|
||||
}
|
||||
return ip, port, true
|
||||
|
|
|
|||
|
|
@ -205,6 +205,10 @@ func (ln *LocalNode) SetFallbackIP(ip net.IP) {
|
|||
// SetFallbackUDP sets the last-resort UDP-on-IPv4 port. This port is used
|
||||
// if no endpoint prediction can be made.
|
||||
func (ln *LocalNode) SetFallbackUDP(port int) {
|
||||
if port < 0 || port > 65535 {
|
||||
log.Error("Invalid port value, must be in range 0-65535", "port", port)
|
||||
return
|
||||
}
|
||||
ln.mu.Lock()
|
||||
defer ln.mu.Unlock()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue