]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Use arc4random instead of random in tests (because it is
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 26 Jan 2016 09:15:22 +0000 (09:15 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 26 Jan 2016 09:15:22 +0000 (09:15 +0000)
  available, possibly as compat, anyway).

git-svn-id: file:///svn/unbound/trunk@3607 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
testcode/delayer.c
testcode/streamtcp.c

index 78d68fd00062b5853e1cde6df52a100f8985a61e..1c8221018fe8145786e95b5eaacbf3b5beb1ecc9 100644 (file)
@@ -1,5 +1,7 @@
 26 January 2016: Wouter
        - Fix #734: chown the pidfile if it resides inside the chroot.
+       - Use arc4random instead of random in tests (because it is
+         available, possibly as compat, anyway).
 
 25 January 2016: Wouter
        - Fix #738: Swig should not be invoked with CPPFLAGS.
index 050cbd23e759bc5ba1225d13df0c656344affb2c..5489b591e3377b87446dc89ac08dbc30cdd35adc 100644 (file)
@@ -1042,7 +1042,7 @@ service(const char* bind_str, int bindport, const char* serv_str,
        }
        i=0;
        if(bindport == 0) {
-               bindport = 1024 + random()%64000;
+               bindport = 1024 + arc4random()%64000;
                i = 100;
        }
        while(1) {
@@ -1058,7 +1058,7 @@ service(const char* bind_str, int bindport, const char* serv_str,
 #endif
                        if(i--==0)
                                fatal_exit("cannot bind any port");
-                       bindport = 1024 + random()%64000;
+                       bindport = 1024 + arc4random()%64000;
                } else break;
        }
        fd_set_nonblock(s);
@@ -1138,7 +1138,6 @@ int main(int argc, char** argv)
        verbosity = 0;
        log_init(0, 0, 0);
        log_ident_set("delayer");
-       srandom(time(NULL) ^ getpid());
        if(argc == 1) usage(argv);
        while( (c=getopt(argc, argv, "b:d:f:hm:p:")) != -1) {
                switch(c) {
index c5919428a52ee1d5cbbaf5c1926ebde15146d7fb..b78506beb5df00b8c942c5abf2d0c3503c63ac45 100644 (file)
@@ -265,7 +265,7 @@ static int get_random(void)
        if (RAND_bytes((unsigned char*)&r, (int)sizeof(r)) == 1) {
                return r;
        }
-       return (int)random();
+       return arc4random();
 }
 
 /** send the TCP queries and print answers */