Public bug reported:
jot -r generates same random numbers within one second time so it's
unusable in batch jobs like shell scripts.
There is code for initializing "random" seed:
s = (randomize ? time(0) : STEP_DEF);
/*... snip ....*/
srand((int) s);
Here is an example of this behavior:
rbtz@rbtz-desktop:~$ date +%s; jot -r 1 0 10000000
1309455778
9981995
rbtz@rbtz-desktop:~$ date +%s; jot -r 1 0 10000000
1309455779
2355993
rbtz@rbtz-desktop:~$ date +%s; jot -r 1 0 10000000
1309455779
2355993
rbtz@rbtz-desktop:~$ date +%s; jot -r 1 0 10000000
1309455779
2355993
rbtz@rbtz-desktop:~$ date +%s; jot -r 1 0 10000000
1309455780
3745306
rbtz@rbtz-desktop:~$ date +%s; jot -r 1 0 10000000
1309455780
3745306
As fast fix pid can be added to seed
srandom((int) s ^ (getpid()<<4));
As good fix arc4random or similar mechanism can be used.
** Affects: athena-jot (Ubuntu)
Importance: Undecided
Status: New
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/804355
Title:
jot random number generator broken in batch jobs
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/athena-jot/+bug/804355/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs