[klibc] [PATCH] add mkstemp(3) using entropy from ELF aux vector AT_RANDOM
H. Peter Anvin
hpa at zytor.com
Wed Feb 1 11:14:16 PST 2012
On 01/28/2012 01:15 PM, Thorsten Glaser wrote:
> --- a/usr/klibc/libc_init.c
> +++ b/usr/klibc/libc_init.c
> @@ -34,6 +34,9 @@
> char **environ;
> unsigned int __page_size, __page_shift;
>
> +/* for use with jrand48() and friends */
> +unsigned short __klibc_rand48[3];
> +
> struct auxentry {
> uintptr_t type;
> uintptr_t v;
> @@ -85,6 +88,10 @@ __noreturn __libc_init(uintptr_t * elfdata, void (*onexit) (void))
> case AT_PAGESZ:
> page_size = (unsigned int)(auxentry->v);
> break;
> + case AT_RANDOM:
> + memcpy(__klibc_rand48, (void *)(auxentry->v),
> + sizeof(__klibc_rand48));
> + break;
> }
> auxentry++;
> }
I suspect this kind of automatic seeding violates the POSIX definitions
of these functions. Not 100% sure though.
-hpa
--
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel. I don't speak on their behalf.
More information about the klibc
mailing list