[monitoring-plugins] check_dhcp: Make xid a bit more random

Holger Weiss git at monitoring-plugins.org
Fri Sep 16 10:50:16 CEST 2016


 Module: monitoring-plugins
 Branch: master
 Commit: 8672529b37fc73fbcc15cb2b2ba9b677f37dac5e
 Author: Holger Weiss <holger at zedat.fu-berlin.de>
   Date: Fri Sep 16 09:43:04 2016 +0200
    URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=8672529

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.

---

 plugins-root/check_dhcp.c | 5 ++---
 1 file 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){
 	discover_packet.hlen=ETHERNET_HARDWARE_ADDRESS_LENGTH;
 
 	/*
-	 * transaction ID is supposed to be random.  We won't use the address so
-	 * we don't care about high entropy here.  time(2) is good enough.
+	 * transaction ID is supposed to be random.
 	 */
-	srand(time(NULL));
+	srand(time(NULL)^getpid());
 	packet_xid=random();
 	discover_packet.xid=htonl(packet_xid);
 



More information about the Commits mailing list