? dist/tests.sh Index: dist/extract.h =================================================================== RCS file: /cvsroot/src/external/bsd/tcpdump/dist/extract.h,v retrieving revision 1.8 diff -u -r1.8 extract.h --- dist/extract.h 8 Sep 2017 14:01:12 -0000 1.8 +++ dist/extract.h 24 Feb 2020 16:18:33 -0000 @@ -19,6 +19,37 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ + +/* + * If we have versions of GCC or Clang that support an __attribute__ + * to say "if we're building with unsigned behavior sanitization, + * don't complain about undefined behavior in this function", we + * label these functions with that attribute - we *know* it's undefined + * in the C standard, but we *also* know it does what we want with + * the ISA we're targeting and the compiler we're using. + * + * For GCC 4.9.0 and later, we use __attribute__((no_sanitize_undefined)); + * pre-5.0 GCC doesn't have __has_attribute, and I'm not sure whether + * GCC or Clang first had __attribute__((no_sanitize(XXX)). + * + * For Clang, we check for __attribute__((no_sanitize(XXX)) with + * __has_attribute, as there are versions of Clang that support + * __attribute__((no_sanitize("undefined")) but don't support + * __attribute__((no_sanitize_undefined)). + * + * We define this here, rather than in funcattrs.h, because we + * only want it used here, we don't want it to be broadly used. + * (Any printer will get this defined, but this should at least + * make it harder for people to find.) + */ +#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 409) +#define UNALIGNED_OK __attribute__((no_sanitize_undefined)) +#elif __has_attribute(no_sanitize) +#define UNALIGNED_OK __attribute__((no_sanitize("undefined"))) +#else +#define UNALIGNED_OK +#endif + #ifdef __NetBSD__ #include @@ -139,36 +170,6 @@ */ #include "funcattrs.h" -/* - * If we have versions of GCC or Clang that support an __attribute__ - * to say "if we're building with unsigned behavior sanitization, - * don't complain about undefined behavior in this function", we - * label these functions with that attribute - we *know* it's undefined - * in the C standard, but we *also* know it does what we want with - * the ISA we're targeting and the compiler we're using. - * - * For GCC 4.9.0 and later, we use __attribute__((no_sanitize_undefined)); - * pre-5.0 GCC doesn't have __has_attribute, and I'm not sure whether - * GCC or Clang first had __attribute__((no_sanitize(XXX)). - * - * For Clang, we check for __attribute__((no_sanitize(XXX)) with - * __has_attribute, as there are versions of Clang that support - * __attribute__((no_sanitize("undefined")) but don't support - * __attribute__((no_sanitize_undefined)). - * - * We define this here, rather than in funcattrs.h, because we - * only want it used here, we don't want it to be broadly used. - * (Any printer will get this defined, but this should at least - * make it harder for people to find.) - */ -#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 409) -#define UNALIGNED_OK __attribute__((no_sanitize_undefined)) -#elif __has_attribute(no_sanitize) -#define UNALIGNED_OK __attribute__((no_sanitize("undefined"))) -#else -#define UNALIGNED_OK -#endif - #ifdef LBL_ALIGN /* * The processor doesn't natively handle unaligned loads. Index: dist/print-ah.c =================================================================== RCS file: /cvsroot/src/external/bsd/tcpdump/dist/print-ah.c,v retrieving revision 1.6 diff -u -r1.6 print-ah.c --- dist/print-ah.c 5 Feb 2017 04:05:05 -0000 1.6 +++ dist/print-ah.c 24 Feb 2020 16:18:33 -0000 @@ -39,6 +39,7 @@ #include "netdissect.h" #include "extract.h" +UNALIGNED_OK int ah_print(netdissect_options *ndo, register const u_char *bp) { Index: dist/print-bgp.c =================================================================== RCS file: /cvsroot/src/external/bsd/tcpdump/dist/print-bgp.c,v retrieving revision 1.10 diff -u -r1.10 print-bgp.c --- dist/print-bgp.c 1 Oct 2019 16:06:16 -0000 1.10 +++ dist/print-bgp.c 24 Feb 2020 16:18:33 -0000 @@ -921,6 +921,7 @@ { 0, NULL} }; +UNALIGNED_OK static int decode_multicast_vpn(netdissect_options *ndo, const u_char *pptr, char *buf, u_int buflen) Index: dist/print-esp.c =================================================================== RCS file: /cvsroot/src/external/bsd/tcpdump/dist/print-esp.c,v retrieving revision 1.10 diff -u -r1.10 print-esp.c --- dist/print-esp.c 1 Oct 2019 16:06:16 -0000 1.10 +++ dist/print-esp.c 24 Feb 2020 16:18:33 -0000 @@ -654,6 +654,7 @@ #endif +UNALIGNED_OK #ifdef HAVE_LIBCRYPTO USES_APPLE_DEPRECATED_API #endif Index: dist/print-icmp.c =================================================================== RCS file: /cvsroot/src/external/bsd/tcpdump/dist/print-icmp.c,v retrieving revision 1.10 diff -u -r1.10 print-icmp.c --- dist/print-icmp.c 1 Oct 2019 16:06:16 -0000 1.10 +++ dist/print-icmp.c 24 Feb 2020 16:18:33 -0000 @@ -331,6 +331,7 @@ return buf; } +UNALIGNED_OK void icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *bp2, int fragmented) Index: dist/print-icmp6.c =================================================================== RCS file: /cvsroot/src/external/bsd/tcpdump/dist/print-icmp6.c,v retrieving revision 1.12 diff -u -r1.12 print-icmp6.c --- dist/print-icmp6.c 1 Oct 2019 16:06:16 -0000 1.12 +++ dist/print-icmp6.c 24 Feb 2020 16:18:33 -0000 @@ -818,6 +818,7 @@ return; } +UNALIGNED_OK static void rpl_print(netdissect_options *ndo, const struct icmp6_hdr *hdr, @@ -876,6 +877,7 @@ } +UNALIGNED_OK void icmp6_print(netdissect_options *ndo, const u_char *bp, u_int length, const u_char *bp2, int fragmented) @@ -1403,6 +1405,7 @@ #undef ECHECK } +UNALIGNED_OK static void mld6_print(netdissect_options *ndo, const u_char *bp) { @@ -1477,6 +1480,7 @@ return; } +UNALIGNED_OK static void mldv2_query_print(netdissect_options *ndo, const u_char *bp, u_int len) { Index: dist/print-igmp.c =================================================================== RCS file: /cvsroot/src/external/bsd/tcpdump/dist/print-igmp.c,v retrieving revision 1.7 diff -u -r1.7 print-igmp.c --- dist/print-igmp.c 5 Feb 2017 04:05:05 -0000 1.7 +++ dist/print-igmp.c 24 Feb 2020 16:18:33 -0000 @@ -107,6 +107,7 @@ { 0, NULL } }; +UNALIGNED_OK static void print_mtrace(netdissect_options *ndo, register const u_char *bp, register u_int len) Index: dist/print-m3ua.c =================================================================== RCS file: /cvsroot/src/external/bsd/tcpdump/dist/print-m3ua.c,v retrieving revision 1.5 diff -u -r1.5 print-m3ua.c --- dist/print-m3ua.c 8 Sep 2017 14:01:13 -0000 1.5 +++ dist/print-m3ua.c 24 Feb 2020 16:18:33 -0000 @@ -301,6 +301,7 @@ * \ \ * / / */ +UNALIGNED_OK void m3ua_print(netdissect_options *ndo, const u_char *buf, const u_int size) @@ -341,4 +342,3 @@ trunc: ND_PRINT((ndo, "%s", tstr)); } - Index: dist/print-msnlb.c =================================================================== RCS file: /cvsroot/src/external/bsd/tcpdump/dist/print-msnlb.c,v retrieving revision 1.3 diff -u -r1.3 print-msnlb.c --- dist/print-msnlb.c 5 Feb 2017 04:05:05 -0000 1.3 +++ dist/print-msnlb.c 24 Feb 2020 16:18:33 -0000 @@ -52,6 +52,7 @@ /* the protocol is undocumented so we ignore the rest */ }; +UNALIGNED_OK void msnlb_print(netdissect_options *ndo, const u_char *bp) { Index: dist/print-nfs.c =================================================================== RCS file: /cvsroot/src/external/bsd/tcpdump/dist/print-nfs.c,v retrieving revision 1.9 diff -u -r1.9 print-nfs.c --- dist/print-nfs.c 1 Oct 2019 16:06:16 -0000 1.9 +++ dist/print-nfs.c 24 Feb 2020 16:18:33 -0000 @@ -354,6 +354,7 @@ ND_PRINT((ndo, "%s", tstr)); } +UNALIGNED_OK void nfsreply_print_noaddr(netdissect_options *ndo, register const u_char *bp, u_int length, @@ -419,6 +420,7 @@ * Return a pointer to the first file handle in the packet. * If the packet was truncated, return 0. */ +UNALIGNED_OK static const uint32_t * parsereq(netdissect_options *ndo, register const struct sunrpc_msg *rp, register u_int length) @@ -522,6 +524,7 @@ return (parsefn(ndo, dp)); } +UNALIGNED_OK void nfsreq_print_noaddr(netdissect_options *ndo, register const u_char *bp, u_int length, @@ -867,6 +870,7 @@ static int xid_map_next = 0; static int xid_map_hint = 0; +UNALIGNED_OK static int xid_map_enter(netdissect_options *ndo, const struct sunrpc_msg *rp, const u_char *bp) @@ -913,6 +917,7 @@ * Returns 0 and puts NFSPROC_xxx in proc return and * version in vers return, or returns -1 on failure */ +UNALIGNED_OK static int xid_map_find(const struct sunrpc_msg *rp, const u_char *bp, uint32_t *proc, uint32_t *vers) @@ -977,6 +982,7 @@ * Return a pointer to the beginning of the actual results. * If the packet was truncated, return 0. */ +UNALIGNED_OK static const uint32_t * parserep(netdissect_options *ndo, register const struct sunrpc_msg *rp, register u_int length) Index: dist/print-ospf6.c =================================================================== RCS file: /cvsroot/src/external/bsd/tcpdump/dist/print-ospf6.c,v retrieving revision 1.9 diff -u -r1.9 print-ospf6.c --- dist/print-ospf6.c 1 Oct 2019 16:06:16 -0000 1.9 +++ dist/print-ospf6.c 24 Feb 2020 16:18:34 -0000 @@ -724,6 +724,7 @@ return (1); } +UNALIGNED_OK static int ospf6_decode_v3(netdissect_options *ndo, register const struct ospf6hdr *op, @@ -929,6 +930,7 @@ * AT data may be present in Hello and DBDesc packets with the AT-bit set or in * any other packet type, thus decode the AT data regardless of the AT-bit. */ +UNALIGNED_OK static int ospf6_decode_v3_trailer(netdissect_options *ndo, const struct ospf6hdr *op, const u_char *cp, const unsigned len) @@ -956,6 +958,7 @@ return 1; } +UNALIGNED_OK void ospf6_print(netdissect_options *ndo, register const u_char *bp, register u_int length) Index: dist/print-pgm.c =================================================================== RCS file: /cvsroot/src/external/bsd/tcpdump/dist/print-pgm.c,v retrieving revision 1.9 diff -u -r1.9 print-pgm.c --- dist/print-pgm.c 8 Sep 2017 14:01:13 -0000 1.9 +++ dist/print-pgm.c 24 Feb 2020 16:18:34 -0000 @@ -147,6 +147,7 @@ #define PGM_MIN_OPT_LEN 4 +UNALIGNED_OK void pgm_print(netdissect_options *ndo, register const u_char *bp, register u_int length, Index: dist/print-rip.c =================================================================== RCS file: /cvsroot/src/external/bsd/tcpdump/dist/print-rip.c,v retrieving revision 1.7 diff -u -r1.7 print-rip.c --- dist/print-rip.c 5 Feb 2017 04:05:05 -0000 1.7 +++ dist/print-rip.c 24 Feb 2020 16:18:34 -0000 @@ -98,6 +98,7 @@ uint32_t rip_metric; /* cost of route */ }; +UNALIGNED_OK static void rip_entry_print_v1(netdissect_options *ndo, register const struct rip_netinfo *ni) @@ -129,6 +130,7 @@ EXTRACT_32BITS(&ni->rip_metric))); } +UNALIGNED_OK static unsigned rip_entry_print_v2(netdissect_options *ndo, register const struct rip_netinfo *ni, const unsigned remaining) @@ -274,5 +276,3 @@ } } } - - Index: dist/print-ripng.c =================================================================== RCS file: /cvsroot/src/external/bsd/tcpdump/dist/print-ripng.c,v retrieving revision 1.7 diff -u -r1.7 print-ripng.c --- dist/print-ripng.c 8 Sep 2017 14:01:13 -0000 1.7 +++ dist/print-ripng.c 24 Feb 2020 16:18:34 -0000 @@ -110,6 +110,7 @@ return l; } +UNALIGNED_OK void ripng_print(netdissect_options *ndo, const u_char *dat, unsigned int length) { Index: dist/print-sctp.c =================================================================== RCS file: /cvsroot/src/external/bsd/tcpdump/dist/print-sctp.c,v retrieving revision 1.8 diff -u -r1.8 print-sctp.c --- dist/print-sctp.c 5 Feb 2017 04:05:05 -0000 1.8 +++ dist/print-sctp.c 24 Feb 2020 16:18:34 -0000 @@ -495,6 +495,7 @@ return 0; } +UNALIGNED_OK void sctp_print(netdissect_options *ndo, const u_char *bp, /* beginning of sctp packet */ const u_char *bp2, /* beginning of enclosing */ Index: dist/print-tcp.c =================================================================== RCS file: /cvsroot/src/external/bsd/tcpdump/dist/print-tcp.c,v retrieving revision 1.9 diff -u -r1.9 print-tcp.c --- dist/print-tcp.c 1 Oct 2019 16:06:16 -0000 1.9 +++ dist/print-tcp.c 24 Feb 2020 16:18:34 -0000 @@ -156,6 +156,7 @@ IPPROTO_TCP); } +UNALIGNED_OK void tcp_print(netdissect_options *ndo, register const u_char *bp, register u_int length, Index: dist/print-timed.c =================================================================== RCS file: /cvsroot/src/external/bsd/tcpdump/dist/print-timed.c,v retrieving revision 1.6 diff -u -r1.6 print-timed.c --- dist/print-timed.c 5 Feb 2017 04:05:05 -0000 1.6 +++ dist/print-timed.c 24 Feb 2020 16:18:34 -0000 @@ -99,6 +99,7 @@ "DATE", "DATEREQ", "DATEACK", "TRACEON", "TRACEOFF", "MSITE", "MSITEREQ", "TEST", "SETDATE", "SETDATEREQ", "LOOP" }; +UNALIGNED_OK void timed_print(netdissect_options *ndo, register const u_char *bp) Index: dist/print-tipc.c =================================================================== RCS file: /cvsroot/src/external/bsd/tcpdump/dist/print-tipc.c,v retrieving revision 1.3 diff -u -r1.3 print-tipc.c --- dist/print-tipc.c 5 Feb 2017 04:05:05 -0000 1.3 +++ dist/print-tipc.c 24 Feb 2020 16:18:34 -0000 @@ -225,6 +225,7 @@ ND_PRINT((ndo, "%s", tstr)); } +UNALIGNED_OK static void print_internal(netdissect_options *ndo, const struct internal_tipc_pkthdr *ap) { @@ -339,6 +340,7 @@ ND_PRINT((ndo, "%s", tstr)); } +UNALIGNED_OK void tipc_print(netdissect_options *ndo, const u_char *bp, u_int length _U_, u_int caplen _U_) @@ -387,4 +389,3 @@ * c-style: bsd * End: */ - Index: dist/print-udp.c =================================================================== RCS file: /cvsroot/src/external/bsd/tcpdump/dist/print-udp.c,v retrieving revision 1.8 diff -u -r1.8 print-udp.c --- dist/print-udp.c 5 Feb 2017 04:05:05 -0000 1.8 +++ dist/print-udp.c 24 Feb 2020 16:18:34 -0000 @@ -371,6 +371,7 @@ } } +UNALIGNED_OK void udp_print(netdissect_options *ndo, register const u_char *bp, u_int length, register const u_char *bp2, int fragmented) Index: dist/print-wb.c =================================================================== RCS file: /cvsroot/src/external/bsd/tcpdump/dist/print-wb.c,v retrieving revision 1.9 diff -u -r1.9 print-wb.c --- dist/print-wb.c 1 Oct 2019 16:06:16 -0000 1.9 +++ dist/print-wb.c 24 Feb 2020 16:18:34 -0000 @@ -399,6 +399,7 @@ /* * Print whiteboard multicast packets. */ +UNALIGNED_OK void wb_print(netdissect_options *ndo, register const void *hdr, register u_int len)