From 27c63813af1433d827335b5d1d34c2b70eddeb6b Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 11 Apr 2015 18:38:15 +0000 Subject: strcpy() calls replaced with strncpy_s() git-svn-id: http://svn.miranda-ng.org/main/trunk@12772 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/netlib/netlibsock.cpp | 13 +++++++------ src/modules/netlib/netlibupnp.cpp | 3 ++- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'src/modules/netlib') 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) { -- cgit v1.2.3