]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Mend "make check" on Solaris 9 (Autoconf only).
authorDenis Ovsienko <[email protected]>
Sun, 25 Jul 2021 13:29:02 +0000 (14:29 +0100)
committerDenis Ovsienko <[email protected]>
Sun, 25 Jul 2021 13:44:03 +0000 (14:44 +0100)
Sun C 5.9 does not support C99. GCC 4.6.4 recognizes -std=gnu99, but
does not support the z length modifier in printf(3). In either case 18
tests fail in the following manner:

<     [...]: domain [length 0 < 12] (invalid)
---
>     [...]: domain [length 0 < zu] (invalid)

Make these tests conditional and disable them when HAVE_NO_PRINTF_Z is
defined. Modify the Autoconf leg of the build process to define the
macro when printf() does not handle %zu as expected. The CMake leg looks
broken on Solaris 9 with 2.8.9 now, so leave it be for now.

CHANGES
config.h.in
configure
configure.ac
tests/TESTLIST
tests/printf_z.tests [new file with mode: 0644]

diff --git a/CHANGES b/CHANGES
index 7405d8f73d2a35ed76ed5cf2e68a354214c1bc19..3a005bc1f83283e5ab42630171b9866fb83938b7 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -23,6 +23,7 @@ Monthday, Month DD, YYYY by gharris and denis
     Building and testing:
       Handle some Autoconf/make errors better.
       Fix "make releasetar" on AIX and Solaris.
+      Mend "make check" on Solaris 9 with Autoconf.
 
 Wednesday, June 9, 2021 by gharris
   Summary for 4.99.1 tcpdump release
index 365651faf79f7602978e08b73699967233e76e1b..5c37b1dccf9d08c929b4e28764994ab0787fdc39 100644 (file)
@@ -78,6 +78,9 @@
 /* Define to 1 if you have the <net/pfvar.h> header file. */
 #undef HAVE_NET_PFVAR_H
 
+/* Define to 1 if printf(3) does not support the z length modifier. */
+#undef HAVE_NO_PRINTF_Z
+
 /* Define to 1 if you have the `openat' function. */
 #undef HAVE_OPENAT
 
index dfe570ae17635f37bce8272ae20c14b0c370caf3..d2a610d4e6d3f2abf9c9df74e3a607e5f5bfb497 100755 (executable)
--- a/configure
+++ b/configure
@@ -4999,6 +4999,54 @@ else
 fi
 
 
+#
+# Define HAVE_NO_PRINTF_Z to make it possible to disable test cases that
+# depend on %zu.
+#
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether printf(3) supports the z length modifier" >&5
+$as_echo_n "checking whether printf(3) supports the z length modifier... " >&6; }
+if test "$cross_compiling" = yes; then :
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot run test program while cross compiling
+See \`config.log' for more details" "$LINENO" 5; }
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+
+#include <stdio.h>
+#include <string.h>
+
+int main()
+{
+  char buf[100];
+  snprintf(buf, sizeof(buf), "%zu", sizeof(buf));
+  return strncmp(buf, "100", sizeof(buf)) ? 1 : 0;
+}
+
+
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+else
+
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+$as_echo "#define HAVE_NO_PRINTF_Z 1" >>confdefs.h
+
+
+
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lrpc" >&5
 $as_echo_n "checking for main in -lrpc... " >&6; }
 if ${ac_cv_lib_rpc_main+:} false; then :
index 7d768d254e802dd823ea3f3cc24591048f886439..9567d51cfea178cffc89d280d841d347abb6c766 100644 (file)
@@ -397,6 +397,35 @@ AC_CHECK_FUNC(vsnprintf,,
 AC_CHECK_FUNC(snprintf,,
     AC_MSG_ERROR([snprintf() is required but wasn't found]))
 
+#
+# Define HAVE_NO_PRINTF_Z to make it possible to disable test cases that
+# depend on %zu.
+#
+AC_MSG_CHECKING([whether printf(3) supports the z length modifier])
+AC_RUN_IFELSE(
+    [
+        AC_LANG_SOURCE([[
+#include <stdio.h>
+#include <string.h>
+
+int main()
+{
+  char buf[100];
+  snprintf(buf, sizeof(buf), "%zu", sizeof(buf));
+  return strncmp(buf, "100", sizeof(buf)) ? 1 : 0;
+}
+        ]])
+    ],
+    [
+        AC_MSG_RESULT(yes)
+    ],
+    [
+        AC_MSG_RESULT(no)
+        AC_DEFINE(HAVE_NO_PRINTF_Z, 1,
+            [Define to 1 if printf(3) does not support the z length modifier.])
+    ]
+)
+
 AC_CHECK_LIB(rpc, main)                dnl It's unclear why we might need -lrpc
 
 dnl Some platforms may need -lnsl for getrpcbynumber.
index 8fa5d7898e96972f4dd7d7a23008c4c04befc076..08ac040f9e51e8ec5c279c7cb0f081647de57434 100644 (file)
@@ -108,15 +108,15 @@ mpls-over-udp  mpls-over-udp.pcap  mpls-over-udp.out
 mpls-over-udp-v  mpls-over-udp.pcap  mpls-over-udp-v.out -v
 
 # OSPF tests
-ospf-gmpls     ospf-gmpls.pcap                         ospf-gmpls.out          -v
-ospf-nssa-bitnt        ospf-nssa-bitnt.pcap                    ospf-nssa-bitnt.out     -v
-ospf3_ah-vv    OSPFv3_with_AH.pcap                     ospf3_ah-vv.out         -v -v
+# In printf_z.tests:
+# ospf-gmpls
+# ospf-nssa-bitnt
+# ospf3_ah-vv
+# ospf3_bc-vv
+# ospf3_mp-vv
+# ospf3_nbma-vv
+# ospf2-seg-fault-1-v (fuzzed pcap)
 ospf3_auth-vv  ospf3_auth.pcapng                       ospf3_auth-vv.out       -v -v
-ospf3_bc-vv    OSPFv3_broadcast_adjacency.pcap         ospf3_bc-vv.out         -v -v
-ospf3_mp-vv    OSPFv3_multipoint_adjacencies.pcap      ospf3_mp-vv.out         -v -v
-ospf3_nbma-vv  OSPFv3_NBMA_adjacencies.pcap            ospf3_nbma-vv.out       -v -v
-# fuzzed pcap
-ospf2-seg-fault-1-v  ospf2-seg-fault-1.pcapng  ospf2-seg-fault-1-v.out  -v
 
 # IKEv2 tests
 ikev2four      ikev2four.pcap          ikev2four.out   -v
@@ -287,7 +287,8 @@ geonet-calm-fast    geonet_and_calm_fast.pcap       geonet_and_calm_fast.out        -vv
 
 # M3UA tests
 m3ua isup.pcap isup.out
-m3ua-vv isup.pcap isupvv.out -vv
+# In printf_z.tests:
+# m3ua-vv
 
 # NFLOG test case
 nflog-e nflog.pcap nflog-e.out -e
@@ -369,7 +370,8 @@ isis-seg-fault-3-v isis-seg-fault-3.pcapng isis-seg-fault-3-v.out -v
 isis_sid       isis_sid.pcap                   isis_sid.out    -v
 
 # RSVP tests
-rsvp_infloop-v rsvp-infinite-loop.pcap         rsvp_infloop-v.out      -v
+# In printf_z.tests:
+# rsvp_infloop-v
 rsvp_cap       rsvp_cap.pcap                   rsvp_cap.out            -v
 # fuzzed pcap
 rsvp-inf-loop-2-v rsvp-inf-loop-2.pcapng       rsvp-inf-loop-2-v.out -v
@@ -381,7 +383,8 @@ hdlc3       HDLC.pcap               hdlc3.out
 hdlc4  hdlc_slarp.pcapng       hdlc4.out
 
 # DECnet test case
-decnet         DECnet_Phone.pcap       decnet.out
+# In printf_z.tests:
+# decnet
 
 # RADIUS tests
 radius-v       RADIUS.pcap     radius-v.out    -v
@@ -610,14 +613,16 @@ icmp-cksum-oobr-3 icmp-cksum-oobr-3.pcapng        icmp-cksum-oobr-3.out   -vvv -e
 icmp-cksum-oobr-4      icmp-cksum-oobr-4.pcapng        icmp-cksum-oobr-4.out   -vvv -e
 tok2str-oobr-1         tok2str-oobr-1.pcap             tok2str-oobr-1.out      -vvv -e
 tok2str-oobr-2         tok2str-oobr-2.pcap             tok2str-oobr-2.out      -vvv -e
-eigrp-tlv-oobr         eigrp-tlv-oobr.pcap             eigrp-tlv-oobr.out      -vvv -e
+# In printf_z.tests:
+#eigrp-tlv-oobr
 zephyr-oobr            zephyr-oobr.pcap                zephyr-oobr.out         -vvv -e
 isakmp-no-none-np      isakmp-no-none-np.pcapng        isakmp-no-none-np.out   -vvv -e
 telnet-iac-check-oobr  telnet-iac-check-oobr.pcap      telnet-iac-check-oobr.out       -vvv -e
 resp_4_infiniteloop    resp_4_infiniteloop.pcapng      resp_4_infiniteloop.out -vvv -e
 dns_fwdptr             dns_fwdptr.pcap                 dns_fwdptr.out          -vvv -e
-isis-areaaddr-oobr-1   isis-areaaddr-oobr-1.pcap       isis-areaaddr-oobr-1.out                -vvv -e
-isis-areaaddr-oobr-2   isis-areaaddr-oobr-2.pcap       isis-areaaddr-oobr-2.out                -vvv -e
+# In printf_z.tests:
+# isis-areaaddr-oobr-1
+# isis-areaaddr-oobr-2
 isis-extd-ipreach-oobr isis-extd-ipreach-oobr.pcap     isis-extd-ipreach-oobr.out              -vvv -e
 lldp-infinite-loop-1   lldp-infinite-loop-1.pcap       lldp-infinite-loop-1.out                -vvv -e
 lldp-infinite-loop-2   lldp-infinite-loop-2.pcap       lldp-infinite-loop-2.out                -vvv -e
@@ -635,7 +640,8 @@ juniper_es_oobr             juniper_es_oobr.pcap            juniper_es_oobr.out     -vvv -e
 
 # bad packets from Yannick Formaggio
 l2tp-avp-overflow      l2tp-avp-overflow.pcap          l2tp-avp-overflow.out   -v
-pktap-heap-overflow    pktap-heap-overflow.pcap        pktap-heap-overflow.out -v
+# In printf_z.tests:
+# pktap-heap-overflow
 wb-oobr                        wb-oobr.pcap                    wb-oobr.out     -v
 
 # bad packets from Bhargava Shastry
@@ -776,9 +782,10 @@ nfs-cannot-pad-32-bit nfs-cannot-pad-32-bit.pcap nfs-cannot-pad-32-bit.out
 #
 # See http://marc.info/?l=tcpdump-workers&m=95552439022555
 #
-dns-zlip-1             dns-zlip-1.pcap         dns-zlip-1.out
-dns-zlip-2             dns-zlip-2.pcap         dns-zlip-2.out
-dns-zlip-3             dns-zlip-3.pcap         dns-zlip-3.out
+# In printf_z.tests:
+# dns-zlip-1
+# dns-zlip-2
+# dns-zlip-3
 
 # NTP tests
 ntp                    ntp.pcap                ntp.out
@@ -839,7 +846,8 @@ arista-ether-ev          arista_ether.pcap        arista_ether-ev.out      -ev
 huge-tipc-messages     huge-tipc-messages.pcap huge-tipc-messages.out
 
 # CVE-2018-10105 bad packets from Luis Rocha
-sflow_print-segv sflow_print-segv.pcap sflow_print-segv.out -v
+# In printf_z.tests:
+# sflow_print-segv
 # two more in smb.tests
 
 #ptp tests
diff --git a/tests/printf_z.tests b/tests/printf_z.tests
new file mode 100644 (file)
index 0000000..a08199d
--- /dev/null
@@ -0,0 +1,132 @@
+# -*- perl -*-
+
+$testlist = [
+    {
+        config_unset => 'HAVE_NO_PRINTF_Z',
+        name => 'ospf-gmpls',
+        input => 'ospf-gmpls.pcap',
+        output => 'ospf-gmpls.out',
+        args   => '-v'
+    },
+    {
+        config_unset => 'HAVE_NO_PRINTF_Z',
+        name => 'ospf-nssa-bitnt',
+        input => 'ospf-nssa-bitnt.pcap',
+        output => 'ospf-nssa-bitnt.out',
+        args   => '-v'
+    },
+    {
+        config_unset => 'HAVE_NO_PRINTF_Z',
+        name => 'ospf3_ah-vv',
+        input => 'OSPFv3_with_AH.pcap',
+        output => 'ospf3_ah-vv.out',
+        args   => '-vv'
+    },
+    {
+        config_unset => 'HAVE_NO_PRINTF_Z',
+        name => 'ospf3_bc-vv',
+        input => 'OSPFv3_broadcast_adjacency.pcap',
+        output => 'ospf3_bc-vv.out',
+        args   => '-vv'
+    },
+    {
+        config_unset => 'HAVE_NO_PRINTF_Z',
+        name => 'ospf3_mp-vv',
+        input => 'OSPFv3_multipoint_adjacencies.pcap',
+        output => 'ospf3_mp-vv.out',
+        args   => '-vv'
+    },
+    {
+        config_unset => 'HAVE_NO_PRINTF_Z',
+        name => 'ospf3_nbma-vv',
+        input => 'OSPFv3_NBMA_adjacencies.pcap',
+        output => 'ospf3_nbma-vv.out',
+        args   => '-vv'
+    },
+    {
+        config_unset => 'HAVE_NO_PRINTF_Z',
+        name => 'ospf2-seg-fault-1-v',
+        input => 'ospf2-seg-fault-1.pcapng',
+        output => 'ospf2-seg-fault-1-v.out',
+        args   => '-v'
+    },
+    {
+        config_unset => 'HAVE_NO_PRINTF_Z',
+        name => 'm3ua-vv',
+        input => 'isup.pcap',
+        output => 'isupvv.out',
+        args   => '-vv'
+    },
+    {
+        config_unset => 'HAVE_NO_PRINTF_Z',
+        name => 'rsvp_infloop-v',
+        input => 'rsvp-infinite-loop.pcap',
+        output => 'rsvp_infloop-v.out',
+        args   => '-v'
+    },
+    {
+        config_unset => 'HAVE_NO_PRINTF_Z',
+        name => 'decnet',
+        input => 'DECnet_Phone.pcap',
+        output => 'decnet.out',
+        args   => ''
+    },
+    {
+        config_unset => 'HAVE_NO_PRINTF_Z',
+        name => 'eigrp-tlv-oobr',
+        input => 'eigrp-tlv-oobr.pcap',
+        output => 'eigrp-tlv-oobr.out',
+        args   => '-vvv -e'
+    },
+    {
+        config_unset => 'HAVE_NO_PRINTF_Z',
+        name => 'isis-areaaddr-oobr-1',
+        input => 'isis-areaaddr-oobr-1.pcap',
+        output => 'isis-areaaddr-oobr-1.out',
+        args   => '-vvv -e'
+    },
+    {
+        config_unset => 'HAVE_NO_PRINTF_Z',
+        name => 'isis-areaaddr-oobr-2',
+        input => 'isis-areaaddr-oobr-2.pcap',
+        output => 'isis-areaaddr-oobr-2.out',
+        args   => '-vvv -e'
+    },
+    {
+        config_unset => 'HAVE_NO_PRINTF_Z',
+        name => 'pktap-heap-overflow',
+        input => 'pktap-heap-overflow.pcap',
+        output => 'pktap-heap-overflow.out',
+        args   => '-v'
+    },
+    {
+        config_unset => 'HAVE_NO_PRINTF_Z',
+        name => 'dns-zlip-1',
+        input => 'dns-zlip-1.pcap',
+        output => 'dns-zlip-1.out',
+        args   => ''
+    },
+    {
+        config_unset => 'HAVE_NO_PRINTF_Z',
+        name => 'dns-zlip-2',
+        input => 'dns-zlip-2.pcap',
+        output => 'dns-zlip-2.out',
+        args   => ''
+    },
+    {
+        config_unset => 'HAVE_NO_PRINTF_Z',
+        name => 'dns-zlip-3',
+        input => 'dns-zlip-3.pcap',
+        output => 'dns-zlip-3.out',
+        args   => ''
+    },
+    {
+        config_unset => 'HAVE_NO_PRINTF_Z',
+        name => 'sflow_print-segv',
+        input => 'sflow_print-segv.pcap',
+        output => 'sflow_print-segv.out',
+        args   => '-v'
+    },
+];
+
+1;