[25844] in CVS-changelog-for-Kerberos-V5

home help back first fref pref prev next nref lref last post

svn rev #25334: trunk/src/lib/crypto/krb/

daemon@ATHENA.MIT.EDU (hartmans@mit.edu)
Fri Oct 14 10:40:23 2011

Date: Fri, 14 Oct 2011 10:40:21 -0400
From: hartmans@mit.edu
Message-Id: <201110141440.p9EEeLC5027147@drugstore.mit.edu>
To: cvs-krb5@mit.edu
Reply-To: krbdev@mit.edu
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: cvs-krb5-bounces@mit.edu

http://src.mit.edu/fisheye/changelog/krb5/?cs=25334
Commit By: hartmans
Log Message:
Fix windows fork detection

Signed-off-by: Kevin Wasserman <kevin.wasserman@painless-security.com>


Changed Files:
U   trunk/src/lib/crypto/krb/prng_fortuna.c
Modified: trunk/src/lib/crypto/krb/prng_fortuna.c
===================================================================
--- trunk/src/lib/crypto/krb/prng_fortuna.c	2011-10-14 14:40:17 UTC (rev 25333)
+++ trunk/src/lib/crypto/krb/prng_fortuna.c	2011-10-14 14:40:20 UTC (rev 25334)
@@ -343,7 +343,9 @@
 
 static k5_mutex_t fortuna_lock = K5_MUTEX_PARTIAL_INITIALIZER;
 static struct fortuna_state main_state;
-#ifndef _WIN32
+#ifdef _WIN32
+static DWORD last_pid;
+#else
 static pid_t last_pid;
 #endif
 static krb5_boolean have_entropy = FALSE;
@@ -359,7 +361,9 @@
         return ret;
 
     init_state(&main_state);
-#ifndef _WIN32
+#ifdef _WIN32
+    last_pid = GetCurrentProcessId();
+#else
     last_pid = getpid();
 #endif
     if (k5_get_os_entropy(osbuf, sizeof(osbuf))) {
@@ -411,10 +415,12 @@
 krb5_c_random_make_octets(krb5_context context, krb5_data *outdata)
 {
     krb5_error_code ret;
-#ifndef _WIN32
+#ifdef _WIN32
+    DWORD pid = GetCurrentProcessId();
+#else
     pid_t pid = getpid();
+#endif
     unsigned char pidbuf[4];
-#endif
 
     ret = k5_mutex_lock(&fortuna_lock);
     if (ret)
@@ -425,14 +431,12 @@
         return KRB5_CRYPTO_INTERNAL;
     }
 
-#ifndef _WIN32 /* no 'fork' on windows; does not apply */
     if (pid != last_pid) {
         /* We forked; make sure child's PRNG stream differs from parent's. */
         store_32_be(pid, pidbuf);
         generator_reseed(&main_state, pidbuf, 4);
         last_pid = pid;
     }
-#endif
 
     accumulator_output(&main_state, (unsigned char *)outdata->data,
                        outdata->length);

_______________________________________________
cvs-krb5 mailing list
cvs-krb5@mit.edu
https://mailman.mit.edu/mailman/listinfo/cvs-krb5

home help back first fref pref prev next nref lref last post