diff options
author | 2014-01-18 07:10:26 +0000 | |
---|---|---|
committer | 2014-01-18 07:10:26 +0000 | |
commit | a1182f85f0d1dccbcc8ef65f9ea3496b7b0f80a3 (patch) | |
tree | c1d2ce0c9d1f201ea4b7ef80854f5121ef195146 | |
parent | Remove -Wbounded: it is now the compiler default. (diff) | |
download | wireguard-openbsd-a1182f85f0d1dccbcc8ef65f9ea3496b7b0f80a3.tar.xz wireguard-openbsd-a1182f85f0d1dccbcc8ef65f9ea3496b7b0f80a3.zip |
Use arc4random_buf() for fetching 64-bits of data because it is faster
than calling arc4random() twice
ok jsing
-rw-r--r-- | sys/nfs/nfs_vnops.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/sys/nfs/nfs_vnops.c b/sys/nfs/nfs_vnops.c index c20ac33c9c3..4a149e6b143 100644 --- a/sys/nfs/nfs_vnops.c +++ b/sys/nfs/nfs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_vnops.c,v 1.149 2013/12/26 07:17:15 espie Exp $ */ +/* $OpenBSD: nfs_vnops.c,v 1.150 2014/01/18 07:10:26 deraadt Exp $ */ /* $NetBSD: nfs_vnops.c,v 1.62.4.1 1996/07/08 20:26:52 jtc Exp $ */ /* @@ -1356,8 +1356,7 @@ again: if (fmode & O_EXCL) { *tl = txdr_unsigned(NFSV3CREATE_EXCLUSIVE); tl = nfsm_build(&info.nmi_mb, NFSX_V3CREATEVERF); - *tl++ = arc4random(); - *tl = arc4random(); + arc4random_buf(tl, sizeof(*tl) * 2); } else { *tl = txdr_unsigned(NFSV3CREATE_UNCHECKED); nfsm_v3attrbuild(&info.nmi_mb, vap, 0); @@ -2518,8 +2517,11 @@ nfs_sillyrename(struct vnode *dvp, struct vnode *vp, struct componentname *cnp) /* Try lookitups until we get one that isn't there */ while (1) { /* Fudge together a funny name */ + u_int32_t rnd[2]; + + arc4random_buf(&rnd, sizeof rnd); sp->s_namlen = snprintf(sp->s_name, sizeof sp->s_name, - ".nfs%08X%08X", arc4random(), arc4random()); + ".nfs%08X%08X", rnd[0], rnd[1]); if (sp->s_namlen > sizeof sp->s_name) sp->s_namlen = strlen(sp->s_name); |