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 23 Feb 2020 00:28:30 -0000 @@ -19,6 +19,36 @@ * 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 +169,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 23 Feb 2020 00:28:30 -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-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 23 Feb 2020 00:28:30 -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 23 Feb 2020 00:28:30 -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 23 Feb 2020 00:28:30 -0000 @@ -876,6 +876,7 @@ } +UNALIGNED_OK void icmp6_print(netdissect_options *ndo, const u_char *bp, u_int length, const u_char *bp2, int fragmented) @@ -1403,6 +1404,7 @@ #undef ECHECK } +UNALIGNED_OK static void mld6_print(netdissect_options *ndo, const u_char *bp) { @@ -1419,6 +1421,7 @@ ND_PRINT((ndo,"addr: %s", ip6addr_string(ndo, &mp->mld6_addr))); } +UNALIGNED_OK static void mldv2_report_print(netdissect_options *ndo, const u_char *bp, u_int len) {