summaryrefslogtreecommitdiff
path: root/lib/util/time.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/util/time.c')
-rw-r--r--lib/util/time.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/util/time.c b/lib/util/time.c
index d5a429af94..56b2ec50de 100644
--- a/lib/util/time.c
+++ b/lib/util/time.c
@@ -450,6 +450,15 @@ _PUBLIC_ char *timestring(TALLOC_CTX *mem_ctx, time_t t)
TimeBuf = talloc_strdup(mem_ctx, tempTime);
#else
TimeBuf = talloc_strdup(mem_ctx, asctime(tm));
+ if (TimeBuf == NULL) {
+ return NULL;
+ }
+ if (TimeBuf[0] != '\0') {
+ size_t len = strlen(TimeBuf);
+ if (TimeBuf[len - 1] == '\n') {
+ TimeBuf[len - 1] = '\0';
+ }
+ }
#endif
return TimeBuf;