From e5f2d9db5035f5db927fa690b13dba944df286a9 Mon Sep 17 00:00:00 2001 From: SharpCoiner Date: Tue, 11 Feb 2014 15:22:10 -0800 Subject: [PATCH] Fixed wrong usage of strftime. Fixed nasty symbols in alethzero messages. The buf length of 9 was too short, there are locales like "HH:MM::SS PM", and who knows what else. Increased buffer to 24, and check for the failure condition. --- libethereum/Common.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libethereum/Common.h b/libethereum/Common.h index 90d920ddb..ff9bedd5b 100644 --- a/libethereum/Common.h +++ b/libethereum/Common.h @@ -187,9 +187,9 @@ public: if ((it != g_logOverride.end() && it->second == true) || (it == g_logOverride.end() && Id::verbosity <= g_logVerbosity)) { time_t rawTime = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); - char buf[9]; - strftime(buf, 9, "%X", localtime(&rawTime)); - + char buf[24]; + if (strftime(buf, 24, "%X", localtime(&rawTime)) == 0) + buf[0] = '\0'; // empty if case strftime fails #if defined(__APPLE__) sstr << Id::name << " [ " << buf << " | " << dispatch_queue_get_label(dispatch_get_current_queue()) << (_term ? " ] " : ""); #else