From 18ae9b3da6ac06c1dee2b10e2c2a816da0e2f4b4 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Tue, 13 May 2003 04:49:15 +0000 Subject: [PATCH] Fixed some string overflows. --- dlls/iphlpapi/ifenum.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/dlls/iphlpapi/ifenum.c b/dlls/iphlpapi/ifenum.c index 6b2de75b186..f512855a655 100644 --- a/dlls/iphlpapi/ifenum.c +++ b/dlls/iphlpapi/ifenum.c @@ -193,7 +193,7 @@ static int isLoopbackInterface(int fd, const char *name) struct ifreq ifr; strncpy(ifr.ifr_name, name, IFNAMSIZ); - ifr.ifr_name[IFNAMSIZ] = '\0'; + ifr.ifr_name[IFNAMSIZ-1] = '\0'; if (ioctl(fd, SIOCGIFFLAGS, &ifr) == 0) ret = ifr.ifr_flags & IFF_LOOPBACK; } @@ -247,7 +247,7 @@ static void storeInterfaceInMap(InterfaceNameMap *map, const char *name) for (ndx = 0; !stored && ndx < map->numAllocated; ndx++) { if (!map->table[ndx].inUse) { strncpy(map->table[ndx].name, name, IFNAMSIZ); - map->table[ndx].name[IFNAMSIZ] = '\0'; + map->table[ndx].name[IFNAMSIZ-1] = '\0'; map->table[ndx].inUse = TRUE; stored = TRUE; if (ndx >= map->nextAvailable) @@ -454,7 +454,7 @@ DWORD getInterfaceIPAddrByName(const char *name) struct ifreq ifr; strncpy(ifr.ifr_name, name, IFNAMSIZ); - ifr.ifr_name[IFNAMSIZ] = '\0'; + ifr.ifr_name[IFNAMSIZ-1] = '\0'; if (ioctl(fd, SIOCGIFADDR, &ifr) == 0) memcpy(&ret, ifr.ifr_addr.sa_data + 2, sizeof(DWORD)); close(fd); @@ -486,7 +486,7 @@ DWORD getInterfaceBCastAddrByName(const char *name) struct ifreq ifr; strncpy(ifr.ifr_name, name, IFNAMSIZ); - ifr.ifr_name[IFNAMSIZ] = '\0'; + ifr.ifr_name[IFNAMSIZ-1] = '\0'; if (ioctl(fd, SIOCGIFBRDADDR, &ifr) == 0) memcpy(&ret, ifr.ifr_addr.sa_data + 2, sizeof(DWORD)); close(fd); @@ -518,7 +518,7 @@ DWORD getInterfaceMaskByName(const char *name) struct ifreq ifr; strncpy(ifr.ifr_name, name, IFNAMSIZ); - ifr.ifr_name[IFNAMSIZ] = '\0'; + ifr.ifr_name[IFNAMSIZ-1] = '\0'; if (ioctl(fd, SIOCGIFNETMASK, &ifr) == 0) memcpy(&ret, ifr.ifr_addr.sa_data + 2, sizeof(DWORD)); close(fd); @@ -555,7 +555,7 @@ DWORD getInterfacePhysicalByName(const char *name, PDWORD len, PBYTE addr, memset(&ifr, 0, sizeof(struct ifreq)); strncpy(ifr.ifr_name, name, IFNAMSIZ); - ifr.ifr_name[IFNAMSIZ] = '\0'; + ifr.ifr_name[IFNAMSIZ-1] = '\0'; if ((ioctl(fd, SIOCGIFHWADDR, &ifr))) ret = ERROR_INVALID_DATA; else { @@ -783,7 +783,7 @@ DWORD getInterfaceMtuByName(const char *name, PDWORD mtu) struct ifreq ifr; strncpy(ifr.ifr_name, name, IFNAMSIZ); - ifr.ifr_name[IFNAMSIZ] = '\0'; + ifr.ifr_name[IFNAMSIZ-1] = '\0'; if ((ioctl(fd, SIOCGIFMTU, &ifr))) ret = ERROR_INVALID_DATA; else { @@ -821,7 +821,7 @@ DWORD getInterfaceStatusByName(const char *name, PDWORD status) struct ifreq ifr; strncpy(ifr.ifr_name, name, IFNAMSIZ); - ifr.ifr_name[IFNAMSIZ] = '\0'; + ifr.ifr_name[IFNAMSIZ-1] = '\0'; if ((ioctl(fd, SIOCGIFFLAGS, &ifr))) ret = ERROR_INVALID_DATA; else {