diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-04-25 22:18:26 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-04-25 22:18:26 +0300 |
commit | 853757df15383c2e9cc33023dc04a256c458e671 (patch) | |
tree | f12cf49d6ddc17b6b4fc96d066359872b108f144 /src/utils | |
parent | 8e57e80d73a58077615924d50ac206d19efddae6 (diff) | |
download | manaplus-853757df15383c2e9cc33023dc04a256c458e671.tar.gz manaplus-853757df15383c2e9cc33023dc04a256c458e671.tar.bz2 manaplus-853757df15383c2e9cc33023dc04a256c458e671.tar.xz manaplus-853757df15383c2e9cc33023dc04a256c458e671.zip |
fix some code style by cpplint.
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/stringutils.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index 88349d407..a07cd1a96 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -78,11 +78,12 @@ const char *ipToString(const int address) { static char asciiIP[18]; - sprintf(asciiIP, "%i.%i.%i.%i", + snprintf(asciiIP, sizeof(asciiIP), "%i.%i.%i.%i", static_cast<unsigned char>(address), static_cast<unsigned char>(address >> 8), static_cast<unsigned char>(address >> 16), static_cast<unsigned char>(address >> 24)); + asciiIP[17] = 0; return asciiIP; } @@ -93,6 +94,7 @@ std::string strprintf(const char *const format, ...) va_list(args); va_start(args, format); int nb = vsnprintf(buf, 256, format, args); + buf[256] = 0; va_end(args); if (nb < 256) return buf; @@ -659,6 +661,7 @@ std::string decodeLinkText(std::string data) std::string toStringPrint(const unsigned int val) { static char str[100]; - sprintf(str, "%u 0x%x", val, val); + snprintf(str, sizeof(str), "%u 0x%x", val, val); + str[99] = 0; return str; } |