From: Jeremie Courreges-Anglas Date: Wed, 4 Oct 2017 23:43:33 +0000 (+0200) Subject: Cast time_t to long long in order to print it. X-Git-Tag: v2.5_beta1~574 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4ac769fb848619dcb39589af29302d8c2d698258;p=thirdparty%2Fopenvpn.git Cast time_t to long long in order to print it. 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 Acked-by: Steffan Karger 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 --- diff --git a/src/openvpn/error.c b/src/openvpn/error.c index 04bf0da5f..7b46c5ec0 100644 --- a/src/openvpn/error.c +++ b/src/openvpn/error.c @@ -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,