cap_server_time: check return values of string functions
This commit is contained in:
parent
2d5f4d8e7f
commit
a2a670824c
1 changed files with 5 additions and 2 deletions
|
@ -58,8 +58,11 @@ cap_server_time_process(hook_data *data)
|
||||||
time_t ts = rb_current_time();
|
time_t ts = rb_current_time();
|
||||||
|
|
||||||
if (!rb_gettimeofday(&tv, NULL)) {
|
if (!rb_gettimeofday(&tv, NULL)) {
|
||||||
strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S.", gmtime(&tv.tv_sec));
|
if (strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S.", gmtime(&tv.tv_sec)) < 0)
|
||||||
rb_snprintf_append(buf, sizeof(buf), "%03uZ", (int)tv.tv_usec / 1000);
|
return;
|
||||||
|
|
||||||
|
if (rb_snprintf_append(buf, sizeof(buf), "%03uZ", (int)tv.tv_usec / 1000) < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
msgbuf_append_tag(msgbuf, "time", buf, CLICAP_SERVER_TIME);
|
msgbuf_append_tag(msgbuf, "time", buf, CLICAP_SERVER_TIME);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue