This patch fixes a bug with the -DPURIFY flag.  The stat structure contains 
padding and unused fields that are not initialized with the stat call.  This 
causes applications such as Valgrind to be unable to analyze OpenSSL 
executables that are compiled with the -DPURIFY flag.

This is for OpenSSL v0.9.8l.  I've tested this on Centos 5.4.

--Kevin


crypto/rand/randfile.c :

@@ -102,6 +102,14 @@



        if (file == NULL) return(0);



+#ifdef PURIFY

+    /* struct stat has padding and unused fields that may not be

+     * initialized in the call to stat().  We need to clear the entire

+     * structure before calling RAND_add() to avoid complaints from

+     * applications such as Valgrind.

+     */

+    memset(&sb, 0, sizeof(sb));

+#endif

        if (stat(file,&sb) < 0) return(0);

        RAND_add(&sb,sizeof(sb),0.0);

        if (bytes == 0) return(ret);



This patch fixes a bug with the –DPURIFY flag.  The stat structure contains padding and unused fields that are not initialized with the stat call.  This causes applications such as Valgrind to be unable to analyze OpenSSL executables that are compiled with the –DPURIFY flag.

 

This is for OpenSSL v0.9.8l.  I’ve tested this on Centos 5.4.

 

--Kevin

 

crypto/rand/randfile.c :
@@ -102,6 +102,14 @@
 
        if (file == NULL) return(0);
 
+#ifdef PURIFY
+    /* struct stat has padding and unused fields that may not be
+     * initialized in the call to stat().  We need to clear the entire
+     * structure before calling RAND_add() to avoid complaints from
+     * applications such as Valgrind.
+     */
+    memset(&sb, 0, sizeof(sb));
+#endif
        if (stat(file,&sb) < 0) return(0);
        RAND_add(&sb,sizeof(sb),0.0);
        if (bytes == 0) return(ret);

 

 

Reply via email to