Re: [Mingw-w64-public] [PATCH] Use rand_s in mkstemp function

2024-03-06 Thread Mateusz Mikuła
Dnia środa, 6 marzec 2024 10:09:30 (+01:00), Martin Storsjö napisał(a): > On Mon, 4 Mar 2024, Martin Storsjö wrote: > > > Looking closer at our mkstemp implementation, we have this loop: > > > >/* > >Like OpenBSD, mkstemp() will try at least 2 ** 31 combinations before > >giv

Re: [Mingw-w64-public] [PATCH] Use rand_s in mkstemp function

2024-03-06 Thread Martin Storsjö
On Mon, 4 Mar 2024, Martin Storsjö wrote: Looking closer at our mkstemp implementation, we have this loop: /* Like OpenBSD, mkstemp() will try at least 2 ** 31 combinations before giving up. */ for (i = 0; i >= 0; i++) { for(j = index; j < len; j++) { t

Re: [Mingw-w64-public] [PATCH] Use rand_s in mkstemp function

2024-03-04 Thread Martin Storsjö
On Mon, 4 Mar 2024, Martin Storsjö wrote: Hi, On Mon, 4 Mar 2024, Mateusz Mikuła wrote: rand is not random enough and may lead to clashing temporary directories with multiple parallel link processes as it was observed on Rust's CI. It can be reproduced with these commands (run them all in wi

Re: [Mingw-w64-public] [PATCH] Use rand_s in mkstemp function

2024-03-03 Thread Martin Storsjö
Hi, On Mon, 4 Mar 2024, Mateusz Mikuła wrote: rand is not random enough and may lead to clashing temporary directories with multiple parallel link processes as it was observed on Rust's CI. It can be reproduced with these commands (run them all in without long pauses): for n in {1..15000}; d

Re: [Mingw-w64-public] [PATCH] Use rand_s in mkstemp function

2024-03-03 Thread LIU Hao
在 2024-03-04 08:04, Mateusz Mikuła 写道: -template_name[j] = letters[rand () % 62]; +if (rand_s (&r)) return -1; +template_name[j] = letters[r % 62]; Does it make sense that if `rand_s()` fails, use `rand()` as a fallback? We have a custom implementation of `r

[Mingw-w64-public] [PATCH] Use rand_s in mkstemp function

2024-03-03 Thread Mateusz Mikuła
rand is not random enough and may lead to clashing temporary directories with multiple parallel link processes as it was observed on Rust's CI. It can be reproduced with these commands (run them all in without long pauses): for n in {1..15000}; do rm -f lib/libLLVMAVRAsmParser.a && \ ar qc lib/l