From d6ce91c0b5258c2e107415704413f42edfab2c30 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 5 Aug 2008 15:53:23 +0200 Subject: guarantee that we never calculate an invalid ip address from the mac address --- avahi-autoipd/main.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'avahi-autoipd') diff --git a/avahi-autoipd/main.c b/avahi-autoipd/main.c index 01ccc79..ef529b9 100644 --- a/avahi-autoipd/main.c +++ b/avahi-autoipd/main.c @@ -1144,9 +1144,13 @@ static int loop(int iface, uint32_t addr) { for (i = 0; i < ETHER_ADDRLEN; i++) a += hw_address[i]*i; + a = (a % 0xFE00) + 0x0100; + addr = htonl(IPV4LL_NETWORK | (uint32_t) a); } + assert(is_ll_address(addr)); + set_state(st, 1, addr); daemon_log(LOG_INFO, "Starting with address %s", inet_ntop(AF_INET, &addr, buf, sizeof(buf))); -- cgit