diff options
author | Eric Faurot <eric@cvs.openbsd.org> | 2013-10-29 13:22:55 +0000 |
---|---|---|
committer | Eric Faurot <eric@cvs.openbsd.org> | 2013-10-29 13:22:55 +0000 |
commit | 5ae47269edd6dcc15f5253ecaad7aaad34d57df2 (patch) | |
tree | ae4d453413e8cd4299208ef4fe20df17c5d16672 /usr.sbin/smtpd | |
parent | 57f552eb05cfcfe4f038b9a270740dfede95b9bc (diff) |
randomize counter part of generated uids
Diffstat (limited to 'usr.sbin/smtpd')
-rw-r--r-- | usr.sbin/smtpd/util.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/usr.sbin/smtpd/util.c b/usr.sbin/smtpd/util.c index 91fd57b7910..715b28eecf4 100644 --- a/usr.sbin/smtpd/util.c +++ b/usr.sbin/smtpd/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.99 2013/10/27 18:50:59 eric Exp $ */ +/* $OpenBSD: util.c,v 1.100 2013/10/29 13:22:54 eric Exp $ */ /* * Copyright (c) 2000,2001 Markus Friedl. All rights reserved. @@ -642,8 +642,13 @@ uint64_t generate_uid(void) { static uint32_t id; + static uint8_t inited; uint64_t uid; + if (!inited) { + id = arc4random(); + inited = 1; + } while ((uid = ((uint64_t)(id++) << 32 | arc4random())) == 0) ; |