Fixed some string overflows.
This commit is contained in:
parent
2bed48d7cd
commit
18ae9b3da6
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue