--- embedaddon/miniupnpd/mac/getifstats.c 2012/02/21 23:16:02 1.1.1.1 +++ embedaddon/miniupnpd/mac/getifstats.c 2012/05/29 12:55:57 1.1.1.2 @@ -1,7 +1,8 @@ +/* $Id: getifstats.c,v 1.1.1.2 2012/05/29 12:55:57 misho Exp $ */ /* * MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ - * (c) 2009 Jarder Weyrich + * (c) 2009 Jardel Weyrich * This software is subject to the conditions detailed * in the LICENCE file provided within the distribution */ @@ -25,7 +26,7 @@ int getifstats(const char * ifname, struct ifdata * da int mib[] = { CTL_NET, PF_ROUTE, 0, AF_INET, NET_RT_IFLIST, if_nametoindex(ifname) }; const size_t mib_len = sizeof(mib) / sizeof(mib[0]); size_t needed; - char *buf, *end; + char *buf, *end, *p; struct if_msghdr *ifm; struct if_data ifdata; #ifdef ENABLE_GETIFSTATS_CACHING @@ -67,8 +68,8 @@ int getifstats(const char * ifname, struct ifdata * da free(buf); return -1; // error } else { - for (end = buf + needed; buf < end; buf += ifm->ifm_msglen) { - ifm = (struct if_msghdr *) buf; + for (end = buf + needed, p = buf; p < end; p += ifm->ifm_msglen) { + ifm = (struct if_msghdr *) p; if (ifm->ifm_type == RTM_IFINFO && ifm->ifm_data.ifi_type == IFT_ETHER) { ifdata = ifm->ifm_data; data->opackets = ifdata.ifi_opackets;