Skip to content

Commit

Permalink
Limit session IDs to a non-negative, pseudo-random int32
Browse files Browse the repository at this point in the history
Technically, this reduces the set from which session IDs are drawn by
(9.999.999.999 - 2.147.483.647) = 7.852.516.352, say 75%.

Practically, ~2e10 possible session IDs should be large enough to avoid
collisions in the real-world.

This fixes an int overflow for 386 architectures.

Fixes carvel-dev#663

Signed-off-by: Max Brauer <[email protected]>
  • Loading branch information
mamachanko committed May 14, 2024
1 parent 16afed5 commit 1095822
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/imgpkg/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func NewSimpleRegistryWithTransport(opts Opts, rTripper http.RoundTripper) (*Sim

sessionID := opts.SessionID
if sessionID == "" {
sessionID = fmt.Sprint(rand.Intn(9999999999))
sessionID = fmt.Sprint(rand.Int31())
}
baseRoundTripper = NewImgpkgRoundTripper(baseRoundTripper, sessionID)

Expand Down

0 comments on commit 1095822

Please sign in to comment.