diff options
author | Damien Miller <djm@mindrot.org> | 1999-11-22 15:24:34 +1100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 1999-11-22 15:24:34 +1100 |
commit | d71b12ee5b6b0283ce41ff2d9c8864c6aadc6bbe (patch) | |
tree | 5e692fe42c86a2142c7e8eae5f9bce252329d219 /helper.c | |
parent | 859cec02509ae0d3e2f34051d0f9d7366b6ca62f (diff) |
- Fix EGD problems (Thanks to Ben Taylor <bent@clark.net>)
- Retry /dev/urandom reads interrupted by signal (report from
Robert Hardy <rhardy@webcon.net>)
Diffstat (limited to 'helper.c')
-rw-r--r-- | helper.c | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -100,8 +100,7 @@ void get_random_bytes(unsigned char *buf, int len) if (sizeof(RANDOM_POOL) > sizeof(addr.sun_path)) fatal("Random pool path is too long"); - strncpy(addr.sun_path, RANDOM_POOL, sizeof(addr.sun_path - 1)); - addr.sun_path[sizeof(addr.sun_path - 1)] = '\0'; + strcpy(addr.sun_path, RANDOM_POOL); addr_len = offsetof(struct sockaddr_un, sun_path) + sizeof(RANDOM_POOL); @@ -130,9 +129,12 @@ void get_random_bytes(unsigned char *buf, int len) #endif /* HAVE_EGD */ - c = read(random_pool, buf, len); - if (c == -1) - fatal("Couldn't read from random pool \"%s\": %s", RANDOM_POOL, strerror(errno)); + do { + c = read(random_pool, buf, len); + + if ((c == -1) && (errno != EINTR)) + fatal("Couldn't read from random pool \"%s\": %s", RANDOM_POOL, strerror(errno)); + } while (c == -1); if (c != len) fatal("Short read from random pool \"%s\"", RANDOM_POOL); |