From a2a670824c8bbc96e5b05c37071fd5875dbf814a Mon Sep 17 00:00:00 2001 From: Simon Arlott Date: Mon, 31 Jul 2017 07:58:06 +0100 Subject: [PATCH] cap_server_time: check return values of string functions --- modules/cap_server_time.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/cap_server_time.c b/modules/cap_server_time.c index 0988587c..06eea3dd 100644 --- a/modules/cap_server_time.c +++ b/modules/cap_server_time.c @@ -58,8 +58,11 @@ cap_server_time_process(hook_data *data) time_t ts = rb_current_time(); if (!rb_gettimeofday(&tv, NULL)) { - strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S.", gmtime(&tv.tv_sec)); - rb_snprintf_append(buf, sizeof(buf), "%03uZ", (int)tv.tv_usec / 1000); + if (strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S.", gmtime(&tv.tv_sec)) < 0) + 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); }