]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Cast time_t to long long in order to print it.
authorJeremie Courreges-Anglas <jca@wxcvbn.org>
Wed, 4 Oct 2017 23:43:33 +0000 (01:43 +0200)
committerGert Doering <gert@greenie.muc.de>
Sat, 4 Nov 2017 18:22:43 +0000 (19:22 +0100)
time_t is only specified as an integer type per POSIX.  To reliably
print it, better cast it to "long long", which is at least 64 bits wide
and can represent values beyond 2038.

Printing as a "long" could cause problems on ILP32 systems using a 64
bits time_t (eg OpenBSD/armv7).

Signed-off-by: Jeremie Courreges-Anglas <jca@wxcvbn.org>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <87efq4havl.fsf@ritchie.wxcvbn.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15640.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 4ac769fb848619dcb39589af29302d8c2d698258)

src/openvpn/error.c

index 04bf0da5f8525f43584c92d8fe8ed15792b92b43..7b46c5ec0f7f80f3074693243645f63a31bdae0d 100644 (file)
@@ -342,8 +342,8 @@ x_msg_va(const unsigned int flags, const char *format, va_list arglist)
                 struct timeval tv;
                 gettimeofday(&tv, NULL);
 
-                fprintf(fp, "%lu.%06lu %x %s%s%s%s",
-                        tv.tv_sec,
+                fprintf(fp, "%lld.%06lu %x %s%s%s%s",
+                        (long long)tv.tv_sec,
                         (unsigned long)tv.tv_usec,
                         flags,
                         prefix,