aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGilles Chehade <gilles@poolp.org>2013-10-02 10:20:56 +0200
committerGilles Chehade <gilles@poolp.org>2013-10-02 10:20:56 +0200
commitbf4fec3480a2f9e2e47ad0dbafc0a99521cc9a5a (patch)
treeb8243ac7687136b2843617c93ca061cf12b7d2d0
parentintroduce csprng.c instead of having to pull util.c from everywhere (diff)
downloadOpenSMTPD-bf4fec3480a2f9e2e47ad0dbafc0a99521cc9a5a.tar.xz
OpenSMTPD-bf4fec3480a2f9e2e47ad0dbafc0a99521cc9a5a.zip
randomize counter part of uid's generated with generate_uid()
-rw-r--r--smtpd/util.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/smtpd/util.c b/smtpd/util.c
index 0fdbeaa7..095a9b02 100644
--- a/smtpd/util.c
+++ b/smtpd/util.c
@@ -627,8 +627,13 @@ uint64_t
generate_uid(void)
{
static uint32_t id;
+ static uint8_t inited;
uint64_t uid;
+ if (!inited) {
+ id = csprng_random();
+ inited = 1;
+ }
while ((uid = ((uint64_t)(id++) << 32 | csprng_random())) == 0)
;