Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,10 @@ func AddToPort(portStr string, add uint64) (string, ErrorI) {
if port < MinAllowedPort {
return "", ErrBadPortLowLimit()
}
// check if add would cause overflow when converting to int
if add > math.MaxInt64 {
return "", ErrMaxPort()
}
// add the given number to the port
newPort := port + int(add)
// ensure the new port doesn't exceed the max port number (65535)
Expand Down