]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Add a signedness check for time_t
authorOtto <otto.moerbeek@open-xchange.com>
Wed, 27 Jan 2021 14:21:59 +0000 (15:21 +0100)
committerOtto <otto.moerbeek@open-xchange.com>
Wed, 27 Jan 2021 14:21:59 +0000 (15:21 +0100)
configure.ac
m4/ax_check_sign.m4 [new file with mode: 0644]
pdns/dnsdistdist/configure.ac
pdns/dnsdistdist/m4/ax_check_sign.m4 [new symlink]
pdns/recursordist/configure.ac
pdns/recursordist/m4/ax_check_sign.m4 [new symlink]

index 3922e858310b095e7c83d0b1fc0e6c3be68428da..9d225cfc6304ea2669fcb69daed4520985c4f9a0 100644 (file)
@@ -28,7 +28,9 @@ AC_LANG([C++])
 
 AX_COMPILE_CHECK_SIZEOF(time_t)
 AS_IF([test $ac_size -lt 8], [AC_MSG_ERROR([size of time_t is $ac_size, which is not large enough to fix the y2k38 bug])])
-
+AX_CHECK_SIGN([time_t], [:], [AC_MSG_ERROR([time_t is unsigned, PowerDNS code relies on it being signed])], [
+  #include <sys/types.h>
+])
 PDNS_CHECK_BISON
 PDNS_CHECK_FLEX
 
diff --git a/m4/ax_check_sign.m4 b/m4/ax_check_sign.m4
new file mode 100644 (file)
index 0000000..bc2c3f0
--- /dev/null
@@ -0,0 +1,54 @@
+# ===========================================================================
+#      https://www.gnu.org/software/autoconf-archive/ax_check_sign.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_CHECK_SIGN (TYPE, [ACTION-IF-SIGNED], [ACTION-IF-UNSIGNED], [INCLUDES])
+#
+# DESCRIPTION
+#
+#   Checks whether TYPE is signed or not. If no INCLUDES are specified, the
+#   default includes are used. If ACTION-IF-SIGNED is given, it is
+#   additional shell code to execute when the type is signed. If
+#   ACTION-IF-UNSIGNED is given, it is executed when the type is unsigned.
+#
+#   This macro assumes that the type exists. Therefore the existence of the
+#   type should be checked before calling this macro. For example:
+#
+#     AC_CHECK_HEADERS([wchar.h])
+#     AC_CHECK_TYPE([wchar_t],,[ AC_MSG_ERROR([Type wchar_t not found.]) ])
+#     AX_CHECK_SIGN([wchar_t],
+#       [ AC_DEFINE(WCHAR_T_SIGNED, 1, [Define if wchar_t is signed]) ],
+#       [ AC_DEFINE(WCHAR_T_UNSIGNED, 1, [Define if wchar_t is unsigned]) ], [
+#     #ifdef HAVE_WCHAR_H
+#     #include <wchar.h>
+#     #endif
+#     ])
+#
+# LICENSE
+#
+#   Copyright (c) 2008 Ville Laurikari <vl@iki.fi>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved. This file is offered as-is, without any
+#   warranty.
+
+#serial 7
+
+AU_ALIAS([VL_CHECK_SIGN], [AX_CHECK_SIGN])
+AC_DEFUN([AX_CHECK_SIGN], [
+ typename=`echo $1 | sed "s/@<:@^a-zA-Z0-9_@:>@/_/g"`
+ AC_CACHE_CHECK([whether $1 is signed], ax_cv_decl_${typename}_signed, [
+   AC_TRY_COMPILE([$4],
+     [ int foo @<:@ 1 - 2 * !((($1) -1) < 0) @:>@ ],
+     [ eval "ax_cv_decl_${typename}_signed=\"yes\"" ],
+     [ eval "ax_cv_decl_${typename}_signed=\"no\"" ])])
+ symbolname=`echo $1 | sed "s/@<:@^a-zA-Z0-9_@:>@/_/g" | tr "a-z" "A-Z"`
+ if eval "test \"\${ax_cv_decl_${typename}_signed}\" = \"yes\""; then
+   $2
+ elif eval "test \"\${ax_cv_decl_${typename}_signed}\" = \"no\""; then
+   $3
+ fi
+])dnl
index cd8b4c8b4031691e474b7ae258d8617129dbbb83..bcc4db07e600a947c6cbe175f3628e4fae69fc91 100644 (file)
@@ -11,6 +11,9 @@ AC_LANG([C++])
 
 AX_COMPILE_CHECK_SIZEOF(time_t)
 AS_IF([test $ac_size -lt 8], [AC_MSG_ERROR([size of time_t is $ac_size, which is not large enough to fix the y2k38 bug])])
+AX_CHECK_SIGN([time_t], [:], [AC_MSG_ERROR([time_t is unsigned, PowerDNS code relies on it being signed])], [
+  #include <sys/types.h>
+])
 
 AC_DEFINE([DNSDIST], [1],
   [This is dnsdist]
diff --git a/pdns/dnsdistdist/m4/ax_check_sign.m4 b/pdns/dnsdistdist/m4/ax_check_sign.m4
new file mode 120000 (symlink)
index 0000000..1f2e120
--- /dev/null
@@ -0,0 +1 @@
+../../../m4/ax_check_sign.m4
\ No newline at end of file
index 0e835daeda321c37f6013f157740257c9dcd6e64..7ed55d09c716fe9e4727781a4fa5d269401d8a99 100644 (file)
@@ -27,6 +27,9 @@ AC_LANG([C++])
 
 AX_COMPILE_CHECK_SIZEOF(time_t)
 AS_IF([test $ac_size -lt 8], [AC_MSG_ERROR([size of time_t is $ac_size, which is not large enough to fix the y2k38 bug])])
+AX_CHECK_SIGN([time_t], [:], [AC_MSG_ERROR([time_t is unsigned, PowerDNS code relies on it being signed])], [
+  #include <sys/types.h>
+])
 
 AC_DEFINE([RECURSOR], [1],
   [This is the PowerDNS Recursor]
diff --git a/pdns/recursordist/m4/ax_check_sign.m4 b/pdns/recursordist/m4/ax_check_sign.m4
new file mode 120000 (symlink)
index 0000000..1f2e120
--- /dev/null
@@ -0,0 +1 @@
+../../../m4/ax_check_sign.m4
\ No newline at end of file