diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2013-08-30 17:05:43 -0400 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2013-08-30 17:05:43 -0400 |
| commit | f3ad05347e55de2fd2a500464acde0979df9941f (patch) | |
| tree | 57376b3114e193201dcfe2d08ef2a5bdb693ad30 /node/InetAddress.cpp | |
| parent | 1a7e303f97507842c1a0bfffb27b76277bd43bab (diff) | |
| download | infinitytier-f3ad05347e55de2fd2a500464acde0979df9941f.tar.gz infinitytier-f3ad05347e55de2fd2a500464acde0979df9941f.zip | |
Improve code security posture by replacing sprintf with a safer function.
Diffstat (limited to 'node/InetAddress.cpp')
| -rw-r--r-- | node/InetAddress.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/node/InetAddress.cpp b/node/InetAddress.cpp index 24ec1f62..b2476893 100644 --- a/node/InetAddress.cpp +++ b/node/InetAddress.cpp @@ -32,6 +32,7 @@ #include "Constants.hpp" #include "InetAddress.hpp" +#include "Utils.hpp" namespace ZeroTier { @@ -66,7 +67,7 @@ std::string InetAddress::toString() const #else if (inet_ntop(AF_INET,(const void *)&(_sa.sin.sin_addr.s_addr),buf,sizeof(buf))) { #endif - sprintf(buf2,"%s/%u",buf,(unsigned int)ntohs(_sa.sin.sin_port)); + Utils::snprintf(buf2,sizeof(buf2),"%s/%u",buf,(unsigned int)ntohs(_sa.sin.sin_port)); return std::string(buf2); } break; @@ -76,7 +77,7 @@ std::string InetAddress::toString() const #else if (inet_ntop(AF_INET6,(const void *)&(_sa.sin6.sin6_addr.s6_addr),buf,sizeof(buf))) { #endif - sprintf(buf2,"%s/%u",buf,(unsigned int)ntohs(_sa.sin6.sin6_port)); + Utils::snprintf(buf2,sizeof(buf2),"%s/%u",buf,(unsigned int)ntohs(_sa.sin6.sin6_port)); return std::string(buf2); } break; |
