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: 2 additions & 2 deletions helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/base64"
"fmt"
"html/template"
"io"
"net/http"
"net/url"
)
Expand Down Expand Up @@ -142,14 +143,13 @@ func (cs *csrf) requestToken(r *http.Request) ([]byte, error) {
// fails to function correctly.
func generateRandomBytes(n int) ([]byte, error) {
b := make([]byte, n)
_, err := rand.Read(b)
_, err := io.ReadFull(rand.Reader, b)
// err == nil only if len(b) == n
if err != nil {
return nil, err
}

return b, nil

}

// sameOrigin returns true if URLs a and b share the same origin. The same
Expand Down
Loading