projects
/
fw
/
pdclib
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
tmpfile() implementation now based on /proc/sys/kernel/random/uuid.
[fw/pdclib]
/
platform
/
example
/
functions
/
stdio
/
tmpfile.c
diff --git
a/platform/example/functions/stdio/tmpfile.c
b/platform/example/functions/stdio/tmpfile.c
index 4c55e5d3542a4c4db4f16f14fcd7d8425b6050ec..44b975d36b13a96f2bf8d63717cd680ec230201f 100644
(file)
--- a/
platform/example/functions/stdio/tmpfile.c
+++ b/
platform/example/functions/stdio/tmpfile.c
@@
-24,7
+24,7
@@
extern struct _PDCLIB_file_t * _PDCLIB_filelist;
/* This is an example implementation of tmpfile() fit for use with POSIX
extern struct _PDCLIB_file_t * _PDCLIB_filelist;
/* This is an example implementation of tmpfile() fit for use with POSIX
-
POSIX
kernels.
+ kernels.
*/
struct _PDCLIB_file_t * tmpfile( void )
{
*/
struct _PDCLIB_file_t * tmpfile( void )
{
@@
-32,7
+32,7
@@
struct _PDCLIB_file_t * tmpfile( void )
/* This is the chosen way to get high-quality randomness. Replace as
appropriate.
*/
/* This is the chosen way to get high-quality randomness. Replace as
appropriate.
*/
- FILE * randomsource = fopen( "/
dev/urandom
", "rb" );
+ FILE * randomsource = fopen( "/
proc/sys/kernel/random/uuid
", "rb" );
char filename[ L_tmpnam ];
_PDCLIB_fd_t fd;
if ( randomsource == NULL )
char filename[ L_tmpnam ];
_PDCLIB_fd_t fd;
if ( randomsource == NULL )
@@
-48,9
+48,9
@@
struct _PDCLIB_file_t * tmpfile( void )
use high-quality randomness instead of a pseudo-random sequence to
generate the filename candidate, which is *also* platform-dependent.
*/
use high-quality randomness instead of a pseudo-random sequence to
generate the filename candidate, which is *also* platform-dependent.
*/
- u
int32_
t random;
- fscanf( randomsource, "%
" SCNu32
, &random );
- sprintf( filename, "/tmp/%
010" PRNu32 "
.tmp", random );
+ u
nsigned in
t random;
+ fscanf( randomsource, "%
u"
, &random );
+ sprintf( filename, "/tmp/%
u
.tmp", random );
/* Check if file of this name exists. Note that fopen() is a very weak
check, which does not take e.g. access permissions into account
(file might exist but not readable). Replace with something more
/* Check if file of this name exists. Note that fopen() is a very weak
check, which does not take e.g. access permissions into account
(file might exist but not readable). Replace with something more
@@
-71,7
+71,7
@@
struct _PDCLIB_file_t * tmpfile( void )
close( fd );
return NULL;
}
close( fd );
return NULL;
}
- rc->status = _PDCLIB_filemode( "wb+" ) | _
PDCLIB_LIBBUFFER | _
IOLBF | _PDCLIB_DELONCLOSE;
+ rc->status = _PDCLIB_filemode( "wb+" ) | _IOLBF | _PDCLIB_DELONCLOSE;
rc->handle = fd;
rc->ungetbuf = (unsigned char *)rc + sizeof( struct _PDCLIB_file_t );
rc->filename = (char *)rc->ungetbuf + _PDCLIB_UNGETCBUFSIZE;
rc->handle = fd;
rc->ungetbuf = (unsigned char *)rc + sizeof( struct _PDCLIB_file_t );
rc->filename = (char *)rc->ungetbuf + _PDCLIB_UNGETCBUFSIZE;