diff options
author | brooks <brooks@FreeBSD.org> | 2004-09-01 18:22:14 +0000 |
---|---|---|
committer | brooks <brooks@FreeBSD.org> | 2004-09-01 18:22:14 +0000 |
commit | ba918da2a51c9e7f2352076e0fbab5f3a82f8104 (patch) | |
tree | 0fdc8d4c7e4a1a23a7a359dc70fbd001b86bbe22 /sbin/ifconfig | |
parent | 7f91bb5d9aea96d133ac63690a8e5483654c4503 (diff) | |
download | FreeBSD-src-ba918da2a51c9e7f2352076e0fbab5f3a82f8104.zip FreeBSD-src-ba918da2a51c9e7f2352076e0fbab5f3a82f8104.tar.gz |
Use a spare byte in struct if_data to store the structure size without
increasing it. Add code to ifconfig to use this size to find the
sockaddr_dl after the struct if_data in the routing message. This
allows struct if_data to grow (up to 255 bytes) without breaking
ifconfig.
Submitted by: peter
Diffstat (limited to 'sbin/ifconfig')
-rw-r--r-- | sbin/ifconfig/ifconfig.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 64e8882..858b8a4 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -585,7 +585,10 @@ retry: ifm = (struct if_msghdr *)next; if (ifm->ifm_type == RTM_IFINFO) { - sdl = (struct sockaddr_dl *)(ifm + 1); + if (ifm->ifm_data.ifi_datalen == 0) + ifm->ifm_data.ifi_datalen = sizeof(struct if_data); + sdl = (struct sockaddr_dl *)((char *)ifm + sizeof(struct if_msghdr) - + sizeof(struct if_data) + ifm->ifm_data.ifi_datalen); flags = ifm->ifm_flags; } else { fprintf(stderr, "out of sync parsing NET_RT_IFLIST\n"); |