mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-28 06:13:31 +01:00
Handle unlikely negative time in tor_log_err_sigsafe
Coverity wants this; CID 1130990.
This commit is contained in:
parent
027f4c82eb
commit
6cbd17470d
@ -474,7 +474,7 @@ tor_log_err_sigsafe(const char *m, ...)
|
||||
{
|
||||
va_list ap;
|
||||
const char *x;
|
||||
char timebuf[32];
|
||||
char timebuf[33];
|
||||
time_t now = time(NULL);
|
||||
|
||||
if (!m)
|
||||
@ -483,8 +483,10 @@ tor_log_err_sigsafe(const char *m, ...)
|
||||
int g = log_time_granularity / 1000;
|
||||
now -= now % g;
|
||||
}
|
||||
timebuf[0] = '\0';
|
||||
format_dec_number_sigsafe(now, timebuf, sizeof(timebuf));
|
||||
timebuf[0] = now < 0 ? '-' : ' ';
|
||||
if (now < 0) now = -now;
|
||||
timebuf[1] = '\0';
|
||||
format_dec_number_sigsafe(now, timebuf+1, sizeof(timebuf)-1);
|
||||
tor_log_err_sigsafe_write("\n=========================================="
|
||||
"================== T=");
|
||||
tor_log_err_sigsafe_write(timebuf);
|
||||
|
Loading…
Reference in New Issue
Block a user