Give the UTC stamp a buffer GCC can prove is big enough
This commit is contained in:
parent
f9e209bf2a
commit
f695a4eac6
|
|
@ -95,7 +95,13 @@ std::string utcStampNow() {
|
||||||
#else
|
#else
|
||||||
gmtime_r(&t, &tm);
|
gmtime_r(&t, &tm);
|
||||||
#endif
|
#endif
|
||||||
char b[32];
|
// 64, not 32, purely to keep the compiler quiet. The real output is always 17
|
||||||
|
// characters, but the tm fields are plain ints, so GCC cannot rule out a
|
||||||
|
// nonsense clock and computes a worst case of 61 bytes - warning on every
|
||||||
|
// build. snprintf truncates rather than overflows either way, so this was
|
||||||
|
// never a safety problem; a recurring warning that everyone learns to ignore
|
||||||
|
// is the actual cost.
|
||||||
|
char b[64];
|
||||||
std::snprintf(b, sizeof(b), "%04d-%02d-%02dT%02d:%02dZ", tm.tm_year + 1900, tm.tm_mon + 1,
|
std::snprintf(b, sizeof(b), "%04d-%02d-%02dT%02d:%02dZ", tm.tm_year + 1900, tm.tm_mon + 1,
|
||||||
tm.tm_mday, tm.tm_hour, tm.tm_min);
|
tm.tm_mday, tm.tm_hour, tm.tm_min);
|
||||||
return std::string(b);
|
return std::string(b);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue