Skip to content

bug: rand should be thread safe #16

@ontehfritz

Description

@ontehfritz

ternal/encryption/encryption.go

const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"

var seededRand *rand.Rand = rand.New(rand.NewSource(time.Now().UnixNano()))
https://github.com/apps/copilot-pull-request-reviewer AI
12 minutes ago
The global variable seededRand is not thread-safe. If multiple goroutines call GenerateRandomString concurrently, this can lead to race conditions and data corruption. The rand.Rand type is not safe for concurrent use by multiple goroutines.

Consider using crypto/rand which is thread-safe, or if you must use math/rand, protect access to the shared rand.Rand instance with a mutex.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions