Skip to content

fix: use io.ReadFull(rand.Reader, b) in generateRandomBytes - #210

Open
aoright wants to merge 1 commit into
gorilla:mainfrom
aoright:fix/use-readfull-rand-reader
Open

fix: use io.ReadFull(rand.Reader, b) in generateRandomBytes#210
aoright wants to merge 1 commit into
gorilla:mainfrom
aoright:fix/use-readfull-rand-reader

Conversation

@aoright

@aoright aoright commented Aug 20, 2026

Copy link
Copy Markdown

Summary

  • Replace rand.Read(b) with io.ReadFull(rand.Reader, b) in generateRandomBytes (helpers.go).
  • In newer Go versions (Go 1.24+), crypto/rand.Read terminates the process if a custom rand.Reader fails/short-reads (as tested in TestGenerateRandomBytes). Using io.ReadFull(rand.Reader, b) allows proper error return and handles short reads gracefully.

Signed-off-by: aoright <102943475+aoright@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant