summaryrefslogtreecommitdiff
path: root/networking/udhcp/clientpacket.c
diff options
context:
space:
mode:
authorRuss Dill2002-10-31 19:21:27 +0000
committerRuss Dill2002-10-31 19:21:27 +0000
commitf5ecd43473353ae18421f487284eee085c203052 (patch)
treef53a725938b0899c5fe2c77f832b09e105482d55 /networking/udhcp/clientpacket.c
parent1b6eb9b6ebd7771db9d1bf481569085ff88197de (diff)
downloadbusybox-f5ecd43473353ae18421f487284eee085c203052.zip
busybox-f5ecd43473353ae18421f487284eee085c203052.tar.gz
sync to udhcp 0.9.8
Diffstat (limited to 'networking/udhcp/clientpacket.c')
-rw-r--r--networking/udhcp/clientpacket.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/networking/udhcp/clientpacket.c b/networking/udhcp/clientpacket.c
index ecbd795..86faec9 100644
--- a/networking/udhcp/clientpacket.c
+++ b/networking/udhcp/clientpacket.c
@@ -35,6 +35,10 @@
#include <unistd.h>
#include <netinet/in.h>
#include <arpa/inet.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
#include "dhcpd.h"
@@ -49,7 +53,17 @@ unsigned long random_xid(void)
{
static int initialized;
if (!initialized) {
- srand(time(0));
+ int fd;
+ unsigned long seed;
+
+ fd = open("/dev/urandom", 0);
+ if (fd < 0 || read(fd, &seed, sizeof(seed)) < 0) {
+ LOG(LOG_WARNING, "Could not load seed from /dev/urandom: %s",
+ strerror(errno));
+ seed = time(0);
+ }
+ if (fd >= 0) close(fd);
+ srand(seed);
initialized++;
}
return rand();