From 3e76d439870f2a0d688fd4e0080b9f9f032146df Mon Sep 17 00:00:00 2001 From: Mathias Gumz Date: Sat, 3 Jan 2015 18:39:09 +0100 Subject: Use correct buffer size for number2*() --- src/FbTk/StringUtil.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/FbTk/StringUtil.cc b/src/FbTk/StringUtil.cc index 00d2e88..9cd2c9a 100644 --- a/src/FbTk/StringUtil.cc +++ b/src/FbTk/StringUtil.cc @@ -69,6 +69,9 @@ using std::transform; namespace { +const size_t DIGITS10_ULONGLONGINT = 20; // ULLONG_MAX = 18446744073709551615 +const size_t DIGITS16_ULONGLONGINT = 18; // ULLONG_MAX = 0xffffffffffffffff + template int extractBigNumber(const char* in, T (*extractFunc)(const char*, char**, int), T& out) { @@ -170,14 +173,14 @@ int extractNumber(const std::string& in, unsigned long long& out) { std::string number2String(long long num) { - char s[128]; + char s[DIGITS10_ULONGLONGINT]; snprintf(s, sizeof(s), "%lld", num); return std::string(s); } std::string number2HexString(long long num) { - char s[17]; - snprintf(s, sizeof(s), "%lx", num); + char s[DIGITS16_ULONGLONGINT]; + snprintf(s, sizeof(s), "%llx", num); return std::string(s); } -- cgit v0.11.2