- /* Get a filename candidate. What constitutes a valid filename and
- where temporary files are usually located is platform-dependent,
- which is one reason why this function is located in the platform
- overlay. The other reason is that a *good* implementation should
- use high-quality randomness instead of a pseudo-random sequence to
- generate the filename candidate, which is *also* platform-dependent.
- */
- unsigned int random;
- fscanf( randomsource, "%u", &random );
- sprintf( filename, "/tmp/%u.tmp", random );
+ long long randnum;
+ if( read(urandom, &randnum, sizeof randnum ) != sizeof randnum )
+ {
+ // TODO: errno!
+ close( urandom );
+ return NULL;
+ }
+
+ sprintf( filename, "/tmp/%llx.tmp", randnum );