summaryrefslogtreecommitdiffstats
path: root/lib/timeutils.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/timeutils.c')
-rw-r--r--lib/timeutils.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/timeutils.c b/lib/timeutils.c
index a7459d2b6..9c286aebc 100644
--- a/lib/timeutils.c
+++ b/lib/timeutils.c
@@ -410,14 +410,14 @@ static int format_iso_time(struct tm *tm, suseconds_t usec, int flags, char *buf
tm->tm_year + (long) 1900,
tm->tm_mon + 1, tm->tm_mday);
if (len < 0 || (size_t) len > bufsz)
- return -1;
+ goto err;
bufsz -= len;
p += len;
}
if ((flags & ISO_DATE) && (flags & ISO_TIME)) {
if (bufsz < 1)
- return -1;
+ goto err;
*p++ = (flags & ISO_T) ? 'T' : ' ';
bufsz--;
}
@@ -426,7 +426,7 @@ static int format_iso_time(struct tm *tm, suseconds_t usec, int flags, char *buf
len = snprintf(p, bufsz, "%02d:%02d:%02d", tm->tm_hour,
tm->tm_min, tm->tm_sec);
if (len < 0 || (size_t) len > bufsz)
- return -1;
+ goto err;
bufsz -= len;
p += len;
}
@@ -434,14 +434,14 @@ static int format_iso_time(struct tm *tm, suseconds_t usec, int flags, char *buf
if (flags & ISO_DOTUSEC) {
len = snprintf(p, bufsz, ".%06ld", (long) usec);
if (len < 0 || (size_t) len > bufsz)
- return -1;
+ goto err;
bufsz -= len;
p += len;
} else if (flags & ISO_COMMAUSEC) {
len = snprintf(p, bufsz, ",%06ld", (long) usec);
if (len < 0 || (size_t) len > bufsz)
- return -1;
+ goto err;
bufsz -= len;
p += len;
}
@@ -452,9 +452,12 @@ static int format_iso_time(struct tm *tm, suseconds_t usec, int flags, char *buf
int zmin = abs(tmin % 60);
len = snprintf(p, bufsz, "%+03d:%02d", zhour,zmin);
if (len < 0 || (size_t) len > bufsz)
- return -1;
+ goto err;
}
return 0;
+ err:
+ warnx(_("format_iso_time: buffer overflow."));
+ return -1;
}
/* timeval to ISO 8601 */