mirror of
git://git.musl-libc.org/musl
synced 2024-11-27 12:04:14 +08:00
avoid limited space of random temp file names if clock resolution is low
this is not an issue that was actually hit, but I noticed it during previous changes to __randname: if the resolution of tv_nsec is too low, the space of temp file names obtainable by a thread could plausibly be exhausted. mixing in tv_sec avoids this.
This commit is contained in:
parent
4100279825
commit
a23a3da29b
@ -11,7 +11,7 @@ char *__randname(char *template)
|
||||
unsigned long r;
|
||||
|
||||
__clock_gettime(CLOCK_REALTIME, &ts);
|
||||
r = ts.tv_nsec + __pthread_self()->tid * 65537UL;
|
||||
r = ts.tv_sec + ts.tv_nsec + __pthread_self()->tid * 65537UL;
|
||||
for (i=0; i<6; i++, r>>=5)
|
||||
template[i] = 'A'+(r&15)+(r&16)*2;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user