From f3ad05347e55de2fd2a500464acde0979df9941f Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Fri, 30 Aug 2013 17:05:43 -0400 Subject: Improve code security posture by replacing sprintf with a safer function. --- node/InetAddress.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'node/InetAddress.cpp') 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; -- cgit v1.2.3