arc4random does not reseed after using fork()

Brian Inglis Brian.Inglis@SystematicSW.ab.ca
Sun Jan 28 00:30:21 GMT 2024


On 2024-01-26 16:50, Glenn Strauss via Cygwin wrote:
>> While testing ksh93u+m's recently added SRANDOM variable[1], I have
>> discovered a bug in Cygwin's arc4random function. After using fork(),
>> arc4random does not reseed itself, which causes the results to become
>> predictable[2]. Below is a test case C program exhibiting the bug:
>> ...
>> [1]: https://github.com/ksh93/ksh/commit/00b296c
>> [2]: https://github.com/ksh93/ksh/issues/711

> FYI: There was a thread in Nov 2023 about rand() which might be related.
> rand is not ISO C compliant in Cygwin
> https://cygwin.com/pipermail/cygwin/2023-November/254735.html
> conclusion of that thread:
> https://cygwin.com/pipermail/cygwin/2023-November/254764.html

No newlib man page or libc info but is in man-pages-linux.
Note that arc4random.c appears to be straight from OpenBSD but arc4random.h 
appears to be newlib, so could function docs be added into arc4random.h, perhaps 
based on OpenBSD man page?

-- 
Take care. Thanks, Brian Inglis              Calgary, Alberta, Canada

La perfection est atteinte                   Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter  not when there is no more to add
mais lorsqu'il n'y a plus rien à retirer     but when there is no more to cut
                                  -- Antoine de Saint-Exupéry



More information about the Cygwin mailing list