commit cfb33f56efdccd488cf3acad91ec4ec1924c870a
parent b4f535e8a19fcf60c735b8d58007dd19f128a3a7
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Fri, 6 Oct 2023 15:08:25 -0400
fix rand.Rand not being thread safe
Diffstat:
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/pkg/captcha/captcha.go b/pkg/captcha/captcha.go
@@ -75,8 +75,6 @@ var (
globalStore = NewMemoryStore(CollectNum, Expiration)
)
-var rnd = rand.New(rand.NewSource(time.Now().UnixNano()))
-
// SetCustomStore sets custom storage for captchas, replacing the default
// memory store. This function must be called before generating any captchas.
func SetCustomStore(s Store) {
@@ -124,7 +122,7 @@ func NewWithSolution(seed int64) (id string, answer string, captchaImg string, c
}
func newLen(params Params, isHelpImg bool) (id, b64 string) {
- r := rnd
+ r := rand.New(rand.NewSource(time.Now().UnixNano())) // rand.New is not thread-safe
s := globalStore
if params.Store != nil {
s = params.Store