diff options
author | dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> | 2021-07-13 12:22:13 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-13 12:22:13 +0000 |
commit | 7d6f3c4dc6e5f68eadcaf9d639b79626aab38c74 (patch) | |
tree | d8e8199a0d5c96f24eb22dbb904f3f43642e5f73 /vendor/github.com/google/uuid/version4.go | |
parent | 4458d2230e31c963e740a78878d593cfe6e2f0a5 (diff) | |
download | podman-7d6f3c4dc6e5f68eadcaf9d639b79626aab38c74.tar.gz podman-7d6f3c4dc6e5f68eadcaf9d639b79626aab38c74.tar.bz2 podman-7d6f3c4dc6e5f68eadcaf9d639b79626aab38c74.zip |
Bump github.com/google/uuid from 1.2.0 to 1.3.0
Bumps [github.com/google/uuid](https://github.com/google/uuid) from 1.2.0 to 1.3.0.
- [Release notes](https://github.com/google/uuid/releases)
- [Commits](https://github.com/google/uuid/compare/v1.2.0...v1.3.0)
---
updated-dependencies:
- dependency-name: github.com/google/uuid
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com>
Diffstat (limited to 'vendor/github.com/google/uuid/version4.go')
-rw-r--r-- | vendor/github.com/google/uuid/version4.go | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/vendor/github.com/google/uuid/version4.go b/vendor/github.com/google/uuid/version4.go index 86160fbd0..7697802e4 100644 --- a/vendor/github.com/google/uuid/version4.go +++ b/vendor/github.com/google/uuid/version4.go @@ -27,6 +27,8 @@ func NewString() string { // The strength of the UUIDs is based on the strength of the crypto/rand // package. // +// Uses the randomness pool if it was enabled with EnableRandPool. +// // A note about uniqueness derived from the UUID Wikipedia entry: // // Randomly generated UUIDs have 122 random bits. One's annual risk of being @@ -35,7 +37,10 @@ func NewString() string { // equivalent to the odds of creating a few tens of trillions of UUIDs in a // year and having one duplicate. func NewRandom() (UUID, error) { - return NewRandomFromReader(rander) + if !poolEnabled { + return NewRandomFromReader(rander) + } + return newRandomFromPool() } // NewRandomFromReader returns a UUID based on bytes read from a given io.Reader. @@ -49,3 +54,23 @@ func NewRandomFromReader(r io.Reader) (UUID, error) { uuid[8] = (uuid[8] & 0x3f) | 0x80 // Variant is 10 return uuid, nil } + +func newRandomFromPool() (UUID, error) { + var uuid UUID + poolMu.Lock() + if poolPos == randPoolSize { + _, err := io.ReadFull(rander, pool[:]) + if err != nil { + poolMu.Unlock() + return Nil, err + } + poolPos = 0 + } + copy(uuid[:], pool[poolPos:(poolPos+16)]) + poolPos += 16 + poolMu.Unlock() + + uuid[6] = (uuid[6] & 0x0f) | 0x40 // Version 4 + uuid[8] = (uuid[8] & 0x3f) | 0x80 // Variant is 10 + return uuid, nil +} |