diff options
Diffstat (limited to 'src/modules/netlib')
-rw-r--r-- | src/modules/netlib/netlibsock.cpp | 13 | ||||
-rw-r--r-- | src/modules/netlib/netlibupnp.cpp | 3 |
2 files changed, 9 insertions, 7 deletions
diff --git a/src/modules/netlib/netlibsock.cpp b/src/modules/netlib/netlibsock.cpp index 4bc3be12f4..e53e73bd89 100644 --- a/src/modules/netlib/netlibsock.cpp +++ b/src/modules/netlib/netlibsock.cpp @@ -275,11 +275,11 @@ static NETLIBIPLIST* GetMyIpv6(unsigned flags) SOCKADDR_INET_M *iaddr = (SOCKADDR_INET_M*)ai->ai_addr;
if (ai->ai_family == AF_INET ||
(ai->ai_family == AF_INET6 &&
- (!(flags & 1) || IsAddrGlobal(&iaddr->Ipv6.sin6_addr)))) {
-
- char* szIp = NetlibAddressToString(iaddr);
+ (!(flags & 1) || IsAddrGlobal(&iaddr->Ipv6.sin6_addr))))
+ {
+ char *szIp = NetlibAddressToString(iaddr);
if (szIp)
- strcpy(addr->szIp[i++], szIp);
+ strncpy_s(addr->szIp[i++], szIp, _TRUNCATE);
mir_free(szIp);
}
}
@@ -295,13 +295,14 @@ static NETLIBIPLIST* GetMyIpv4(void) PHOSTENT he = gethostbyname(hostname);
unsigned n;
- for (n = 0; he->h_addr_list[n]; ++n);
+ for (n = 0; he->h_addr_list[n]; ++n)
+ ;
NETLIBIPLIST *addr = (NETLIBIPLIST*)mir_calloc(n * 64 + 4);
addr->cbNum = n;
for (unsigned i = 0; i < n; i++)
- strcpy(addr->szIp[i], inet_ntoa(*(PIN_ADDR)he->h_addr_list[i]));
+ strncpy_s(addr->szIp[i], inet_ntoa(*(PIN_ADDR)he->h_addr_list[i]), _TRUNCATE);
return addr;
}
diff --git a/src/modules/netlib/netlibupnp.cpp b/src/modules/netlib/netlibupnp.cpp index 4e6813b8c9..513aafaa55 100644 --- a/src/modules/netlib/netlibupnp.cpp +++ b/src/modules/netlib/netlibupnp.cpp @@ -343,7 +343,8 @@ retrycon: break;
}
}
- strcpy(szConnHost, szHost); sConnPort = sPort;
+ strncpy_s(szConnHost, szHost, _TRUNCATE);
+ sConnPort = sPort;
}
if (send(sock, szData, sz, 0) != SOCKET_ERROR) {
|