all repos — fluxbox @ 3e76d439870f2a0d688fd4e0080b9f9f032146df

custom fork of the fluxbox windowmanager

Use correct buffer size for number2*()
Mathias Gumz akira@fluxbox.org
commit

3e76d439870f2a0d688fd4e0080b9f9f032146df

parent

362b5c191a15a32de871aeb93d8a2fc4f9ad5648

1 files changed, 6 insertions(+), 3 deletions(-)

jump to
M src/FbTk/StringUtil.ccsrc/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 <typename T> int extractBigNumber(const char* in, T (*extractFunc)(const char*, char**, int), T& out) {

@@ -170,14 +173,14 @@

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); }