Skip to content

Commit

Permalink
fix(cmd/gobgp): parse listen-port as u16, not i16
Browse files Browse the repository at this point in the history
A port is in the range 0..64k, not -32k..32k. Hence unsigned.
  • Loading branch information
Tuetuopay authored and fujita committed Jul 2, 2022
1 parent 89735e9 commit 4df7710
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cmd/gobgp/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -1599,11 +1599,11 @@ func modGlobalConfig(args []string) error {
if id.To4() == nil {
return fmt.Errorf("invalid router-id format")
}
var port int64
var port uint64
if len(m["listen-port"]) > 0 {
// Note: GlobalConfig.Port is uint32 type, but the TCP/UDP port is
// 16-bit length.
port, err = strconv.ParseInt(m["listen-port"][0], 10, 16)
port, err = strconv.ParseUint(m["listen-port"][0], 10, 16)
if err != nil {
return err
}
Expand Down

0 comments on commit 4df7710

Please sign in to comment.