Skip to content

Commit

Permalink
Ensure portNumber is not to large
Browse files Browse the repository at this point in the history
Otherwise we could have a potential integer overflow when converting
to int in the following statement.
  • Loading branch information
arnested committed Sep 18, 2024
1 parent 23eae8f commit 96bfcea
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ func (c Container) Services() map[string]uint16 {
continue
}

if portNumber > 65535 {

Check failure on line 59 in internal/container/container.go

View workflow job for this annotation

GitHub Actions / Lint

Magic number: 65535, in <condition> detected (gomnd)
log.Logf(log.PriErr, "Port number %d is too large", portNumber)
continue

Check failure on line 61 in internal/container/container.go

View workflow job for this annotation

GitHub Actions / Lint

continue with no blank line before (nlreturn)

Check warning on line 61 in internal/container/container.go

View check run for this annotation

Codecov / codecov/patch

internal/container/container.go#L60-L61

Added lines #L60 - L61 were not covered by tests
}

service := netdb.GetServByPort(int(portNumber), proto)

if service == nil || proto == nil {
Expand Down

0 comments on commit 96bfcea

Please sign in to comment.