Merge pull request #283 from DeforaNetworks/khorben/srandom

Seed random() at least a bit before using random()
This commit is contained in:
Michael Rash
2018-08-06 20:49:49 -04:00
committed by GitHub
+3
View File
@@ -250,6 +250,7 @@ send_spa_packet_tcp_raw(const char *spa_data, const int sd_len,
/* Total size is header plus payload */
iph->tot_len = hdrlen + sd_len;
/* The value here does not matter */
srandom(time(NULL) ^ getuid() ^ (getgid() << 16) ^ getpid());
iph->id = random() & 0xffff;
iph->frag_off = 0;
iph->ttl = RAW_SPA_TTL;
@@ -363,6 +364,7 @@ send_spa_packet_udp_raw(const char *spa_data, const int sd_len,
/* Total size is header plus payload */
iph->tot_len = hdrlen + sd_len;
/* The value here does not matter */
srandom(time(NULL) ^ getuid() ^ (getgid() << 16) ^ getpid());
iph->id = random() & 0xffff;
iph->frag_off = 0;
iph->ttl = RAW_SPA_TTL;
@@ -462,6 +464,7 @@ send_spa_packet_icmp(const char *spa_data, const int sd_len,
/* Total size is header plus payload */
iph->tot_len = hdrlen + sd_len;
/* The value here does not matter */
srandom(time(NULL) ^ getuid() ^ (getgid() << 16) ^ getpid());
iph->id = random() & 0xffff;
iph->frag_off = 0;
iph->ttl = RAW_SPA_TTL;