diff options
author | Holger Weiss <holger@zedat.fu-berlin.de> | 2016-09-16 07:43:04 (GMT) |
---|---|---|
committer | Holger Weiss <holger@zedat.fu-berlin.de> | 2016-09-16 07:43:04 (GMT) |
commit | 8672529b37fc73fbcc15cb2b2ba9b677f37dac5e (patch) | |
tree | 9a73e784466efaa452f8dec312b0520e0836abc4 | |
parent | 99f5be29927de6863849441b8af4b794033cc8bd (diff) | |
download | monitoring-plugins-8672529b37fc73fbcc15cb2b2ba9b677f37dac5e.tar.gz |
check_dhcp: Make xid a bit more random
Don't just use the current time(2) to seed the PRNG that generates the
xid. A DHCP server might be checked multiple times per second.
-rw-r--r-- | plugins-root/check_dhcp.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/plugins-root/check_dhcp.c b/plugins-root/check_dhcp.c index 445ddbc..88b7ca1 100644 --- a/plugins-root/check_dhcp.c +++ b/plugins-root/check_dhcp.c | |||
@@ -463,10 +463,9 @@ int send_dhcp_discover(int sock){ | |||
463 | discover_packet.hlen=ETHERNET_HARDWARE_ADDRESS_LENGTH; | 463 | discover_packet.hlen=ETHERNET_HARDWARE_ADDRESS_LENGTH; |
464 | 464 | ||
465 | /* | 465 | /* |
466 | * transaction ID is supposed to be random. We won't use the address so | 466 | * transaction ID is supposed to be random. |
467 | * we don't care about high entropy here. time(2) is good enough. | ||
468 | */ | 467 | */ |
469 | srand(time(NULL)); | 468 | srand(time(NULL)^getpid()); |
470 | packet_xid=random(); | 469 | packet_xid=random(); |
471 | discover_packet.xid=htonl(packet_xid); | 470 | discover_packet.xid=htonl(packet_xid); |
472 | 471 | ||