svn commit: lorikeet r46 - in trunk/heimdal/lib/krb5: .

abartlet at samba.org abartlet at samba.org
Mon Sep 6 02:55:07 GMT 2004


Author: abartlet
Date: 2004-09-06 02:55:06 +0000 (Mon, 06 Sep 2004)
New Revision: 46

WebSVN: http://websvn.samba.org/websvn/changeset.php?rep=lorikeet&path=/trunk/heimdal/lib/krb5&rev=46&nolog=1

Log:
Adding uninitialised memory into the entorpy pool is a sure-fire way
to get valgrind errors.

(This didn't fix all of them - OpenSSL is still a problem - but it's a
start).

Andrew Bartlett

Modified:
   trunk/heimdal/lib/krb5/crypto.c


Changeset:
Modified: trunk/heimdal/lib/krb5/crypto.c
===================================================================
--- trunk/heimdal/lib/krb5/crypto.c	2004-09-06 02:53:38 UTC (rev 45)
+++ trunk/heimdal/lib/krb5/crypto.c	2004-09-06 02:55:06 UTC (rev 46)
@@ -3724,6 +3724,7 @@
 seed_something(void)
 {
     int fd = -1;
+    size_t bytes;
     char buf[1024], seedfile[256];
 
     /* If there is a seed file, load it. But such a file cannot be trusted,
@@ -3731,9 +3732,13 @@
     if (RAND_file_name(seedfile, sizeof(seedfile))) {
 	fd = open(seedfile, O_RDONLY);
 	if (fd >= 0) {
-	    read(fd, buf, sizeof(buf));
-	    /* Use the full buffer anyway */
-	    RAND_add(buf, sizeof(buf), 0.0);
+	    bytes = read(fd, buf, sizeof(buf));
+	    if (bytes > 0) {
+		RAND_add(buf, bytes, 0.0);
+	    } else {
+	        seedfile[0] = '\0';
+	    }
+	    close(fd);
 	} else
 	    seedfile[0] = '\0';
     } else



More information about the samba-cvs mailing list