From: Roy Marples Date: Wed, 4 May 2016 13:05:52 +0000 (+0000) Subject: Remove random() from a potential htonl() macro which could call it more than once. X-Git-Tag: v6.11.0~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5ffcfc3feeb23e3ae42b190a304fc54456bbeefb;p=thirdparty%2Fdhcpcd.git Remove random() from a potential htonl() macro which could call it more than once. --- diff --git a/ipv4ll.c b/ipv4ll.c index 8203433a..14427be5 100644 --- a/ipv4ll.c +++ b/ipv4ll.c @@ -58,12 +58,15 @@ ipv4ll_pick_addr(const struct arp_state *astate) setstate(istate->randomstate); do { + long r; + /* RFC 3927 Section 2.1 states that the first 256 and * last 256 addresses are reserved for future use. * See ipv4ll_start for why we don't use arc4_random. */ /* coverity[dont_call] */ + r = random(); addr.s_addr = ntohl(LINKLOCAL_ADDR | - ((uint32_t)(random() % 0xFD00) + 0x0100)); + ((uint32_t)(r % 0xFD00) + 0x0100)); /* No point using a failed address */ if (addr.s_addr == astate->failed.s_addr)