summaryrefslogtreecommitdiff
path: root/lib/util
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2013-06-13 21:55:43 +0200
committerJeremy Allison <jra@samba.org>2013-06-14 20:29:56 +0200
commitc71d6ecbcb463dca64118652e941bb0a162d306f (patch)
tree90ff96a8afb38ab632e7892e9a21fe105ad61dd8 /lib/util
parentdd0e38b5feb51c8aa44e76bb6c84202bf8373005 (diff)
downloadsamba-c71d6ecbcb463dca64118652e941bb0a162d306f.tar.gz
samba-c71d6ecbcb463dca64118652e941bb0a162d306f.tar.bz2
samba-c71d6ecbcb463dca64118652e941bb0a162d306f.zip
genrand: Slightly simplify do_reseed
The only caller set "use_fd" to "true". Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Fri Jun 14 20:29:56 CEST 2013 on sn-devel-104
Diffstat (limited to 'lib/util')
-rw-r--r--lib/util/genrand.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/lib/util/genrand.c b/lib/util/genrand.c
index 3dfaf089d1..0e5902fea9 100644
--- a/lib/util/genrand.c
+++ b/lib/util/genrand.c
@@ -163,25 +163,23 @@ static void do_filehash(const char *fname, unsigned char *the_hash)
above...
**************************************************************/
-static int do_reseed(bool use_fd, int fd)
+static int do_reseed(int fd)
{
unsigned char seed_inbuf[40];
uint32_t v1, v2; struct timeval tval; pid_t mypid;
int reseed_data = 0;
- if (use_fd) {
- if (fd == -1) {
- fd = open( "/dev/urandom", O_RDONLY,0);
- if (fd != -1) {
- smb_set_close_on_exec(fd);
- }
- }
- if (fd != -1
- && (read(fd, seed_inbuf, sizeof(seed_inbuf)) == sizeof(seed_inbuf))) {
- seed_random_stream(seed_inbuf, sizeof(seed_inbuf));
- return fd;
+ if (fd == -1) {
+ fd = open( "/dev/urandom", O_RDONLY,0);
+ if (fd != -1) {
+ smb_set_close_on_exec(fd);
}
}
+ if (fd != -1
+ && (read(fd, seed_inbuf, sizeof(seed_inbuf)) == sizeof(seed_inbuf))) {
+ seed_random_stream(seed_inbuf, sizeof(seed_inbuf));
+ return fd;
+ }
/* Add in some secret file contents */
@@ -244,7 +242,7 @@ _PUBLIC_ void generate_random_buffer(uint8_t *out, int len)
}
}
- urand_fd = do_reseed(true, urand_fd);
+ urand_fd = do_reseed(urand_fd);
done_reseed = true;
}