• Mike Frysinger's avatar
    ifconfig: use sockaddr_storage to hold addresses · d87ceba5
    Mike Frysinger authored
    Currently, we pass around sockaddr to various locations where they
    might case things to IPv4 or IPv6 addresses.  In the latter case,
    this struct is not large enough to hold an IPv6 address, so we end
    up smashing the stack.
    
    For example:
    	ifconfig sit1 inet6 pointopoint ::1.2.3.4
    This calls ap->input() with an IPv6 address but a sockaddr struct.
    Internally, we cast this to sockaddr_in6 and then write too much.
    
    Rather than fixing this one cast, change the code to use the new
    sockaddr_storage struct.  Then point sockaddr_in and sockaddr_in6
    to that location.  This way we can use "sa" everywhere and then
    use "sin" and "sin6" automatically (since they point to the same
    storage).
    
    URL: http://sourceforge.net/p/net-tools/bugs/3/Signed-off-by: default avatarMike Frysinger <vapier@gentoo.org>
    d87ceba5
ifconfig.c 28.2 KB