(seed_something): avoid poking at memory that is uninitialized, make
valgrind unhappy. Pointd out by abartlet@samba.org. While where, plug the fd leak. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@14193 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -3723,17 +3723,19 @@ krb5_decrypt_EncryptedData(krb5_context context,
|
|||||||
static int
|
static int
|
||||||
seed_something(void)
|
seed_something(void)
|
||||||
{
|
{
|
||||||
int fd = -1;
|
|
||||||
char buf[1024], seedfile[256];
|
char buf[1024], seedfile[256];
|
||||||
|
|
||||||
/* If there is a seed file, load it. But such a file cannot be trusted,
|
/* If there is a seed file, load it. But such a file cannot be trusted,
|
||||||
so use 0 for the entropy estimate */
|
so use 0 for the entropy estimate */
|
||||||
if (RAND_file_name(seedfile, sizeof(seedfile))) {
|
if (RAND_file_name(seedfile, sizeof(seedfile))) {
|
||||||
|
int fd;
|
||||||
fd = open(seedfile, O_RDONLY);
|
fd = open(seedfile, O_RDONLY);
|
||||||
if (fd >= 0) {
|
if (fd >= 0) {
|
||||||
read(fd, buf, sizeof(buf));
|
ssize_t ret;
|
||||||
/* Use the full buffer anyway */
|
ret = read(fd, buf, sizeof(buf));
|
||||||
RAND_add(buf, sizeof(buf), 0.0);
|
if (ret > 0)
|
||||||
|
RAND_add(buf, ret, 0.0);
|
||||||
|
close(fd);
|
||||||
} else
|
} else
|
||||||
seedfile[0] = '\0';
|
seedfile[0] = '\0';
|
||||||
} else
|
} else
|
||||||
|
Reference in New Issue
Block a user