]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Fix the flushing of addresses on BSD systems.
authorRoy Marples <roy@marples.name>
Mon, 20 Aug 2007 19:09:12 +0000 (19:09 +0000)
committerRoy Marples <roy@marples.name>
Mon, 20 Aug 2007 19:09:12 +0000 (19:09 +0000)
ChangeLog
interface.c

index cdbff48830c0538df11f6cd4f62034b471ba6856..6deeab2f92ab073f47d5ea4eef0f923e92eb9a35 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,5 @@
 dhcpcd-3.1.5
+Fix the flushing of addresses on BSD systems.
 Rework the arp code again so that we don't link to librt on Linux.
 Thanks to regenrecht for reporting the below three overflows:-
  Fix a potential buffer overflow in hwaddr_ntoa if length > 42.
index 7ff3ad16a2ac6608f6aba7e749437daec7f8945b..3502fecc9d340169001bdc1a30bee3d4607304fe 100644 (file)
@@ -198,8 +198,16 @@ static int _do_interface (const char *ifname,
        }
 
        for (p = ifc.ifc_buf; p < ifc.ifc_buf + ifc.ifc_len;) {
-               struct ifreq *ifr = (struct ifreq *) p;
+               union {
+                       char *buffer;
+                       struct ifreq *ifr;
+               } ifreqs;
                struct sockaddr_in address;
+               struct ifreq *ifr;
+
+               /* Cast the ifc buffer to an ifreq cleanly */
+               ifreqs.buffer = p;
+               ifr = ifreqs.ifr;
 
 #ifdef __linux__
                p += sizeof (struct ifreq);
@@ -977,12 +985,7 @@ int del_route (const char *ifname, struct in_addr destination,
 
 int flush_addresses (const char *ifname)
 {
-       struct in_addr address;
-       unsigned char buf[1024];
-       int len = 0;
-
-       memset (buf, 0, 1023);
-       return (_do_interface (ifname, buf, &len, &address, true, false));
+       return (_do_interface (ifname, NULL, NULL, NULL, true, false));
 }
 
 unsigned long get_address (const char *ifname)