From 7e4de3c22888f51ab1e8e48ec7acd44d272c2aac Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sun, 24 Mar 2013 01:35:37 +0000 Subject: [PATCH] Compile contrib/tzcode/stdtime/localtime.c with -fwrapv, since it relies on signed integer overflow wrapping. Otherwise mktime(3) and timegm(3) can hang, in case the timestamp passed in struct tm is not representable in a time_t. Specifically, any timestamp after 2038-01-19 03:14:07, in combination with a 32-bit time_t. Note that it would be better to change the code to not rely on undefined behaviour, but it is contributed code, and it is not entirely trivial to fix the issue properly. MFC after: 3 days --- lib/libc/stdtime/Makefile.inc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/libc/stdtime/Makefile.inc b/lib/libc/stdtime/Makefile.inc index 0cc038afcdf5..477049f4640b 100644 --- a/lib/libc/stdtime/Makefile.inc +++ b/lib/libc/stdtime/Makefile.inc @@ -11,6 +11,9 @@ SYM_MAPS+= ${.CURDIR}/stdtime/Symbol.map CFLAGS+= -I${.CURDIR}/../../contrib/tzcode/stdtime -I${.CURDIR}/stdtime +CFLAGS.localtime.c= -fwrapv +CFLAGS+= ${CFLAGS.${.IMPSRC:T}} + MAN+= ctime.3 strftime.3 strptime.3 time2posix.3 MAN+= tzfile.5