Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/makefs Revert arc4random usage. makefs is only used...



details:   https://anonhg.NetBSD.org/src/rev/14e4408a9754
branches:  trunk
changeset: 551510:14e4408a9754
user:      fvdl <fvdl%NetBSD.org@localhost>
date:      Sun Sep 07 14:24:08 2003 +0000

description:
Revert arc4random usage. makefs is only used for install images,
filehandle randomization is not an issue there, and using arc4random
broke building makefs as a host tool.

diffstat:

 usr.sbin/makefs/ffs.c      |   7 ++++---
 usr.sbin/makefs/ffs/mkfs.c |  12 ++++++------
 2 files changed, 10 insertions(+), 9 deletions(-)

diffs (78 lines):

diff -r 32644937ac31 -r 14e4408a9754 usr.sbin/makefs/ffs.c
--- a/usr.sbin/makefs/ffs.c     Sun Sep 07 14:14:36 2003 +0000
+++ b/usr.sbin/makefs/ffs.c     Sun Sep 07 14:24:08 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ffs.c,v 1.21 2003/09/06 12:42:00 itojun Exp $  */
+/*     $NetBSD: ffs.c,v 1.22 2003/09/07 14:24:08 fvdl Exp $    */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -67,7 +67,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: ffs.c,v 1.21 2003/09/06 12:42:00 itojun Exp $");
+__RCSID("$NetBSD: ffs.c,v 1.22 2003/09/07 14:24:08 fvdl Exp $");
 #endif /* !__lint */
 
 #include <sys/param.h>
@@ -1029,8 +1029,9 @@
            initediblk < ufs_rw32(cgp->cg_niblk, fsopts->needswap)) {
                memset(buf, 0, fs->fs_bsize);
                dip = (struct ufs2_dinode *)buf;
+               srandom(time(NULL));
                for (i = 0; i < INOPB(fs); i++) {
-                       dip->di_gen = (arc4random() & INT32_MAX) / 2 + 1;
+                       dip->di_gen = random() / 2 + 1;
                        dip++;
                }
                ffs_wtfs(fsbtodb(fs, ino_to_fsba(fs,
diff -r 32644937ac31 -r 14e4408a9754 usr.sbin/makefs/ffs/mkfs.c
--- a/usr.sbin/makefs/ffs/mkfs.c        Sun Sep 07 14:14:36 2003 +0000
+++ b/usr.sbin/makefs/ffs/mkfs.c        Sun Sep 07 14:24:08 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mkfs.c,v 1.17 2003/09/06 12:44:34 itojun Exp $ */
+/*     $NetBSD: mkfs.c,v 1.18 2003/09/07 14:24:09 fvdl Exp $   */
 
 /*
  * Copyright (c) 2002 Networks Associates Technology, Inc.
@@ -44,7 +44,7 @@
 static char sccsid[] = "@(#)mkfs.c     8.11 (Berkeley) 5/3/95";
 #else
 #ifdef __RCSID
-__RCSID("$NetBSD: mkfs.c,v 1.17 2003/09/06 12:44:34 itojun Exp $");
+__RCSID("$NetBSD: mkfs.c,v 1.18 2003/09/07 14:24:09 fvdl Exp $");
 #endif
 #endif
 #endif /* not lint */
@@ -438,7 +438,7 @@
        sblock.fs_clean = FS_ISCLEAN;
        sblock.fs_ronly = 0;
        sblock.fs_id[0] = start_time.tv_sec;
-       sblock.fs_id[1] = arc4random() & INT32_MAX;
+       sblock.fs_id[1] = random();
        sblock.fs_fsmnt[0] = '\0';
        csfrags = howmany(sblock.fs_cssize, sblock.fs_fsize);
        sblock.fs_dsize = sblock.fs_size - sblock.fs_sblkno -
@@ -743,10 +743,10 @@
        for (i = 0; i < acg.cg_initediblk; i++) {
                if (sblock.fs_magic == FS_UFS1_MAGIC) {
                        /* No need to swap, it'll stay random */
-                       dp1->di_gen = arc4random() & INT32_MAX;
+                       dp1->di_gen = random();
                        dp1++;
                } else {
-                       dp2->di_gen = arc4random() & INT32_MAX;
+                       dp2->di_gen = random();
                        dp2++;
                }
        }
@@ -761,7 +761,7 @@
                     i += sblock.fs_frag) {
                        dp1 = (struct ufs1_dinode *)(&iobuf[start]);
                        for (j = 0; j < INOPB(&sblock); j++) {
-                               dp1->di_gen = arc4random() & INT32_MAX;
+                               dp1->di_gen = random();
                                dp1++;
                        }
                        ffs_wtfs(fsbtodb(&sblock, cgimin(&sblock, cylno) + i),



Home | Main Index | Thread Index | Old Index