This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
strfry patch
- From: James A Morrison <ja2morri at student dot math dot uwaterloo dot ca>
- To: libc-alpha at sources dot redhat dot com
- Date: Sat, 9 Mar 2002 17:15:13 -0500 (EST)
- Subject: strfry patch
Hi,
To provide the illusion of more randomness, strfry now seeds it's rng
with time % pid so while(sleep 0.1); do ./strfry "Fun stff"; done
will provide a differnt fried string for each process.
Index: strfry.c
===================================================================
RCS file: /cvs/glibc/libc/string/strfry.c,v
retrieving revision 1.6
diff -u -r1.6 strfry.c
--- strfry.c 2001/07/06 04:55:41 1.6
+++ strfry.c 2002/03/09 22:02:04
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992, 1996, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1992, 1996, 1999, 2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -31,7 +31,7 @@
{
static char state[32];
rdata.state = NULL;
- __initstate_r (time ((time_t *) NULL), state, sizeof (state), &rdata);
+ __initstate_r (time ((time_t *) NULL) % getpid (), state, sizeof (state), &rdata);
init = 1;
}