[Freeswitch-svn] [commit] r12281 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/su
FreeSWITCH SVN
mikej at freeswitch.org
Wed Feb 25 11:34:54 PST 2009
Author: mikej
Date: Wed Feb 25 13:34:54 2009
New Revision: 12281
Log:
Wed Feb 25 11:29:23 CST 2009 Pekka Pessi <first.last at nokia.com>
* su_uniqueid.c: fixed seed array usage
Ignore-this: b6e6a195f3f34abc2119a741f8b6f5e2
Paper bags, anyone?
Modified:
freeswitch/trunk/libs/sofia-sip/.update
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_uniqueid.c
Modified: freeswitch/trunk/libs/sofia-sip/.update
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/.update (original)
+++ freeswitch/trunk/libs/sofia-sip/.update Wed Feb 25 13:34:54 2009
@@ -1 +1 @@
-Wed Feb 25 13:30:44 CST 2009
+Wed Feb 25 13:31:50 CST 2009
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_uniqueid.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_uniqueid.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_uniqueid.c Wed Feb 25 13:34:54 2009
@@ -136,11 +136,14 @@
{
int i;
+#define N_SEED 32
+
#if HAVE_INITSTATE
/* Allow libsofia-sip-ua.so to unload. */
- uint32_t *seed = calloc(32, sizeof(uint32_t));
+ uint32_t *seed = calloc(N_SEED, sizeof *seed);
#else
- static uint32_t seed[32] = { 0 };
+ static uint32_t _seed[N_SEED] = { 0 };
+ uint32_t *seed = _seed;
#endif
su_time_t now;
@@ -153,25 +156,25 @@
#endif /* HAVE_DEV_URANDOM */
if (urandom) {
- size_t len = fread(seed, sizeof seed, 1, urandom); (void)len;
+ size_t len = fread(seed, sizeof *seed, N_SEED, urandom); (void)len;
}
else {
- for (i = 0; i < 16; i++) {
+ for (i = 0; i < N_SEED; i += 2) {
#if HAVE_CLOCK_GETTIME
struct timespec ts;
(void)clock_gettime(CLOCK_REALTIME, &ts);
- seed[2*i] ^= ts.tv_sec; seed[2*i+1] ^= ts.tv_nsec;
+ seed[i] ^= ts.tv_sec; seed[i + 1] ^= ts.tv_nsec;
#endif
su_time(&now);
- seed[2*i] ^= now.tv_sec; seed[2*i+1] ^= now.tv_sec;
+ seed[i] ^= now.tv_sec; seed[i + 1] ^= now.tv_sec;
}
- seed[30] ^= getuid();
- seed[31] ^= getpid();
+ seed[0] ^= getuid();
+ seed[1] ^= getpid();
}
#if HAVE_INITSTATE
- initstate(seed[0] ^ seed[1], (char *)seed, 32 * sizeof(uint32_t));
+ initstate(seed[0] ^ seed[1], (void *)seed, N_SEED * (sizeof *seed));
#else
srand(seed[0] ^ seed[1]);
#endif
More information about the Freeswitch-svn
mailing list