Lib: Fix handling of buffers in timestamp formatting
The code in tm_format_real_time() mixed up two buffers and their sizes, which may cause crash in MRT dumping code. Thanks to Piotr Wydrych for the bugreport.
This commit is contained in:
parent
a2277975d7
commit
9c41e1ca3e
1 changed files with 3 additions and 2 deletions
|
@ -365,8 +365,9 @@ tm_format_real_time(char *x, size_t max, const char *fmt, btime t)
|
||||||
if (!localtime_r(&ts, &tm))
|
if (!localtime_r(&ts, &tm))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
byte tbuf[TM_DATETIME_BUFFER_SIZE];
|
size_t tbuf_size = MIN(max, 4096);
|
||||||
if (!strfusec(tbuf, max, fmt, t2))
|
byte *tbuf = alloca(tbuf_size);
|
||||||
|
if (!strfusec(tbuf, tbuf_size, fmt, t2))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!strftime(x, max, tbuf, &tm))
|
if (!strftime(x, max, tbuf, &tm))
|
||||||
|
|
Loading…
Reference in a new issue