]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
makefile: compile getdate.o with -fwrapv option
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 26 Jun 2023 11:20:22 +0000 (13:20 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Tue, 18 Jul 2023 12:52:55 +0000 (14:52 +0200)
The getdate code (copied from gnulib before it was switched to GPLv3)
has multiple issues with signed integer overflows. Use the -fwrapv
compiler option for this object to at least make the operations defined.

Makefile.in
configure

index ef100a4b5c9b427422a7b5065dd5a00247eba775..101e0c6961a45b587a8971dd9dc3ccb0f4480aa0 100644 (file)
@@ -33,6 +33,8 @@ CFLAGS = @CFLAGS@
 CPPFLAGS = @CPPFLAGS@
 LDFLAGS = @LDFLAGS@
 
+GETDATE_CFLAGS = @GETDATE_CFLAGS@
+
 EXTRA_OBJS = @EXTRA_OBJS@
 
 OBJS = array.o cmdparse.o conf.o local.o logging.o main.o memory.o quantiles.o \
@@ -61,6 +63,8 @@ chronyd : $(OBJS)
 chronyc : $(CLI_OBJS)
        $(CC) $(CFLAGS) -o chronyc $(CLI_OBJS) $(LDFLAGS) $(LIBS) $(EXTRA_CLI_LIBS)
 
+getdate.o: CFLAGS += $(GETDATE_CFLAGS)
+
 distclean : clean
        $(MAKE) -C doc distclean
        $(MAKE) -C test/unit distclean
index 15c1935af374bcf1cfc1315624725f7ad4ea5df5..d4ab9b58a2f84c1110b9116243d4d9d6026085fb 100755 (executable)
--- a/configure
+++ b/configure
@@ -570,6 +570,13 @@ if [ "x$MYCFLAGS" = "x" ]; then
   fi
 fi
 
+TESTCFLAGS="-fwrapv"
+if test_code '-fwrapv' '' "$TESTCFLAGS" '' ''; then
+  GETDATE_CFLAGS="-fwrapv"
+else
+  GETDATE_CFLAGS=""
+fi
+
 if [ "x$MYCC" = "xgcc" ] || [ "x$MYCC" = "xclang" ]; then
   MYCFLAGS="$MYCFLAGS -Wmissing-prototypes -Wall"
 fi
@@ -1122,6 +1129,7 @@ do
           s%@CFLAGS@%${MYCFLAGS}%;\
           s%@CPPFLAGS@%${MYCPPFLAGS}%;\
           s%@LDFLAGS@%${MYLDFLAGS}%;\
+          s%@GETDATE_CFLAGS@%${GETDATE_CFLAGS}%;\
           s%@LIBS@%${LIBS}%;\
           s%@EXTRA_LIBS@%${EXTRA_LIBS}%;\
           s%@EXTRA_CLI_LIBS@%${EXTRA_CLI_LIBS}%;\