From: Denis Ovsienko Date: Sun, 25 Jul 2021 13:29:02 +0000 (+0100) Subject: Mend "make check" on Solaris 9 (Autoconf only). X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/fbd44158e0d5e6bb0c9b05671f702ebcf68cc56d Mend "make check" on Solaris 9 (Autoconf only). 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. --- diff --git a/CHANGES b/CHANGES index 7405d8f7..3a005bc1 100644 --- 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 diff --git a/config.h.in b/config.h.in index 365651fa..5c37b1dc 100644 --- a/config.h.in +++ b/config.h.in @@ -78,6 +78,9 @@ /* Define to 1 if you have the 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 diff --git a/configure b/configure index dfe570ae..d2a610d4 100755 --- 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 +#include + +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 : diff --git a/configure.ac b/configure.ac index 7d768d25..9567d51c 100644 --- a/configure.ac +++ b/configure.ac @@ -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 +#include + +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. diff --git a/tests/TESTLIST b/tests/TESTLIST index 8fa5d789..08ac040f 100644 --- a/tests/TESTLIST +++ b/tests/TESTLIST @@ -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 index 00000000..a08199d6 --- /dev/null +++ b/tests/printf_z.tests @@ -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;