tcpdump
7 weeks agoIPX: Add two length checks tcpdump-4.99
Francois-Xavier Le Bail [Sat, 6 Nov 2021 15:58:42 +0000 (16:58 +0100)] 
IPX: Add two length checks

This change fixes some undefined behaviors at runtime.

The errors were like:
print-ipx.c:160:12: runtime error: unsigned integer overflow:
  1 - 2 cannot be represented in type 'unsigned int'
print-ipx.c:233:12: runtime error: unsigned integer overflow:
  1 - 2 cannot be represented in type 'unsigned int'

(cherry picked from commit ddf590c14278769bb2e1a7b7a87ce98ae23bc549)

7 weeks agoman: Update the date
Francois-Xavier Le Bail [Mon, 29 Nov 2021 13:05:56 +0000 (14:05 +0100)] 
man: Update the date

7 weeks agoman: Update the print interface for the packet count to stdout
Francois-Xavier Le Bail [Mon, 29 Nov 2021 11:07:03 +0000 (12:07 +0100)] 
man: Update the print interface for the packet count to stdout

This is a follow-up to commit a0e19c0caef95fdcbace674de91e7c181d3bc866.

(cherry picked from commit b27c4e43a2d3ba3a526b72505b713bf6617645e9)

7 weeks agoZEP: Add three length checks
Francois-Xavier Le Bail [Sun, 28 Nov 2021 09:57:14 +0000 (10:57 +0100)] 
ZEP: Add three length checks

(cherry picked from commit 121cd17c7dc1fb0ae2dd0e2e823b4824530314e0)

7 weeks agoEthernet: Add a length check
Francois-Xavier Le Bail [Fri, 5 Nov 2021 20:48:31 +0000 (21:48 +0100)] 
Ethernet: Add a length check

This fix some undefined behaviors at runtime.

The errors were like:

print-ether.c:241:11: runtime error: unsigned integer overflow:
  1 - 2 cannot be represented in type 'unsigned int'
print-ether.c:242:11: runtime error: unsigned integer overflow:
  1 - 2 cannot be represented in type 'unsigned int'

Moreover:
Fix indentation.

(cherry picked from commit c72751f8cdc8bf0f87d26531d24d74aaddf377f2)

7 weeks agoEthernet: Rework the length checks
Francois-Xavier Le Bail [Sun, 21 Nov 2021 14:33:24 +0000 (15:33 +0100)] 
Ethernet: Rework the length checks

Add a sanity check: packet length need to be >= capture length

(Like a sanity check in print.c, pretty_print_packet() function)

Remove a now useless test:
Because packet length (length) >= capture length (caplen), when
caplen >= ETHER_HDRLEN + switch_tag_len, length cannot
be < ETHER_HDRLEN + switch_tag_len.

(cherry picked from commit d52b757efa7b0678e34c0ffe32d1c0da29bbb604)

7 weeks agoPTP: Use ND_LCHECK_U for checking invalid length
Francois-Xavier Le Bail [Mon, 1 Feb 2021 12:44:21 +0000 (13:44 +0100)] 
PTP: Use ND_LCHECK_U for checking invalid length

Moreover:
Rename a variable.

(cherry picked from commit 1c67c0188bc9cd5095154efde3011bb6ac1b3130)

7 weeks agoFix a typo in ND_LCHECK_ZU definition
Francois-Xavier Le Bail [Sun, 17 Jan 2021 09:29:12 +0000 (10:29 +0100)] 
Fix a typo in ND_LCHECK_ZU definition

[skip ci]

(cherry picked from commit 73c5d1e2926b8128a8dc9000a44f36a772756dc3)

7 weeks agoAdd ND_LCHECKMSG_U, ND_LCHECK_U, ND_LCHECKMSG_ZU and ND_LCHECK_ZU macros
Francois-Xavier Le Bail [Sat, 16 Jan 2021 13:27:21 +0000 (14:27 +0100)] 
Add ND_LCHECKMSG_U, ND_LCHECK_U, ND_LCHECKMSG_ZU and ND_LCHECK_ZU macros

They check length < minimum for invalid packet with or without a custom
message, format %u or %zu.

%zu (ND_LCHECKMSG_ZU and ND_LCHECK_ZU) is useful when minimum is a
sizeof(...).

[skip ci]

(cherry picked from commit 014b308d0851ef08c9fe3f1da5576eaae64f3e17)

7 weeks agolwres: Update a variable type
Francois-Xavier Le Bail [Tue, 2 Nov 2021 08:34:45 +0000 (09:34 +0100)] 
lwres: Update a variable type

This should address two AppVeyor/Visual Studio 2019/x64 warnings:
print-lwres.c(197,23): warning C4267: 'function': conversion from
 'size_t' to 'u_int', possible loss of data
print-lwres.c(201,14): warning C4267: 'return': conversion from
 'size_t' to 'unsigned int', possible loss of data

(cherry picked from commit 62ed9474840b96a01a0a696f00c7f83a64074afc)

2 months agoEAP: Fix some undefined behaviors at runtime
Francois-Xavier Le Bail [Thu, 4 Nov 2021 21:56:37 +0000 (22:56 +0100)] 
EAP: Fix some undefined behaviors at runtime

The errors were like:
print-eap.c:179:25: runtime error: unsigned integer overflow:
  2 - 5 cannot be represented in type 'unsigned int'
print-eap.c:181:50: runtime error: unsigned integer overflow:
  2 - 5 cannot be represented in type 'unsigned int'
print-eap.c:186:25: runtime error: unsigned integer overflow:
  2 - 5 cannot be represented in type 'unsigned int'
print-eap.c:188:50: runtime error: unsigned integer overflow:
  2 - 5 cannot be represented in type 'unsigned int'

(cherry picked from commit 58a4ab67fc75b62968634cddec290c1f2e2c1ded)

3 months agoUse the correct section in CHANGES this time. [skip ci]
Denis Ovsienko [Wed, 29 Sep 2021 14:40:21 +0000 (15:40 +0100)] 
Use the correct section in CHANGES this time. [skip ci]

3 months agoCI: Refine GCC identification. [skip appveyor]
Denis Ovsienko [Wed, 15 Sep 2021 08:54:11 +0000 (09:54 +0100)] 
CI: Refine GCC identification. [skip appveyor]

Same as in libpcap.

(cherry picked from commit 7c6a734dff3d95d0ed761be5634e65d25bd9b317)

3 months agoCI: Add MAKE_BIN to allow non-default makes. [skip ci]
Denis Ovsienko [Tue, 17 Aug 2021 19:35:21 +0000 (20:35 +0100)] 
CI: Add MAKE_BIN to allow non-default makes. [skip ci]

This way parallel builds are simpler on Solaris and OpenIndiana.

(cherry picked from commit 4316f615c94976db082c7100d0ff0e33dade238b)

3 months agoDocument some OpenIndiana particulars. [skip ci]
Denis Ovsienko [Tue, 17 Aug 2021 16:39:47 +0000 (17:39 +0100)] 
Document some OpenIndiana particulars. [skip ci]

(cherry picked from commit 4b3055b4bd5d07b5101b68380d7b85c5dc29651d)

3 months agoCI: Clean in ../libpcap only if present. [skip ci]
Denis Ovsienko [Tue, 17 Aug 2021 16:20:32 +0000 (17:20 +0100)] 
CI: Clean in ../libpcap only if present. [skip ci]

./build_matrix.sh[89]: cd: /export/home/denis/libpcap: [No such file or
  directory]

(cherry picked from commit ed0175cddadfac745e0a778937a941261fc53107)

3 months agoFixup commit 604cd4a for OpenIndiana.
Denis Ovsienko [Mon, 16 Aug 2021 22:47:07 +0000 (23:47 +0100)] 
Fixup commit 604cd4a for OpenIndiana.

SunOS openindiana 5.11 illumos-755ccbcfa2 i86pc i386 i86pc
gcc (OpenIndiana 10.3.0-oi-0) 10.3.0

As it turns out, in OpenIndiana 2021.04 ND_UNREACHABLE is one of the
neighbour discovery states in <net/if.h>:

In file included from ./extract.h:40,
                 from ./addrtoname.h:22,
                 from ./addrtoname.c:112:
./diag-control.h:181: warning: "ND_UNREACHABLE" redefined

In file included from ./addrtoname.c:87:
/usr/include/net/if.h:307: note: this is the location of the previous
  definition

In file included from ./extract.h:40,
                 from ./addrtoname.h:22,
                 from ./print-sll.c:36:
./diag-control.h:181: warning: "ND_UNREACHABLE" redefined

In file included from ./print-sll.c:29:
/usr/include/net/if.h:307: note: this is the location of the previous
  definition

(cherry picked from commit 4f1a63c4c3b109d14b4df003baa85cbc373c82f6)

3 months agoUse __builtin_unreachable(). [skip ci]
Denis Ovsienko [Sun, 15 Aug 2021 09:54:50 +0000 (10:54 +0100)] 
Use __builtin_unreachable(). [skip ci]

Same as in libpcap.

(cherry picked from commit 604cd4aa60557f23ee76a60fd8ea339ca2e54e77)

3 months agoDo not define __EXTENSIONS__ if already defined. [skip ci]
Denis Ovsienko [Tue, 10 Aug 2021 09:18:19 +0000 (10:18 +0100)] 
Do not define __EXTENSIONS__ if already defined. [skip ci]

SunOS solaris11-amd64 5.11 11.4.0.15.0 i86pc i386 i86pc
clang version 6.0.0 (tags/RELEASE_600/final)

Every .c file that included netdissect-stdinc.h generated a warning:

In file included from ./netdissect-stdinc.h:42:
./ftmacros.h:48:11: warning: '__EXTENSIONS__' macro redefined
      [-Wmacro-redefined]
<built-in>:345:9: note: previous definition is here

(cherry picked from commit f139f17ba91ac60b36a0db424db01fbedf23a798)

3 months agoTell CMake not to check for a C++ compiler.
Guy Harris [Sun, 8 Aug 2021 18:54:17 +0000 (11:54 -0700)] 
Tell CMake not to check for a C++ compiler.

We only need a C compiler, and if either

1) the C and C++ compilers don't match (e.g., a defaults-to-64-bit GCC
and a defaults-to-32-bit Oracle Studio C++)

or

2) you set CFLAGS in the environment to force a 64-bit build but don't
also set CXXFLAGS

CMake will get confused and think it's doing a 32-bit build even though
we'll be doing a 64-bit build, and all sorts of weirdness will occur.

Just say "C" in the project() command.

(cherry picked from commit 3834579486f1bb4a002e45ceb6c015cd28b84611)

3 months agoOn Solaris, for 64-bit builds, use the 64-bit pcap-config.
Guy Harris [Sun, 8 Aug 2021 07:36:42 +0000 (00:36 -0700)] 
On Solaris, for 64-bit builds, use the 64-bit pcap-config.

There are two versions of pcap-config supplied on Solaris (or, at least,
on 64-bit Solaris) - a version that has the right --libs output to find
the 32-bit libraries and a version that has the right --libs output to
find the 64-bit libraries.

Try to figure out whether we're doing a 32-bit or 64-bit build (based on
the pointer size) and, for 64-bit builds, run the 64-bit version of
pcap-config.

(cherry picked from commit c39d40a767a1ae36171e5bcbf6f157ff3e80fb6c)

3 months agoUse basename() and dirname() right on FreeBSD. [skip appveyor]
Denis Ovsienko [Thu, 5 Aug 2021 13:18:55 +0000 (14:18 +0100)] 
Use basename() and dirname() right on FreeBSD. [skip appveyor]

On FreeBSD CMake runs Clang with -std=gnu99, which used to emit three
warnings in a Capsicum-specific block along the following lines:

tcpdump.c:2432:32: warning: '_Generic' is a C11 extension
  [-Wc11-extensions]
/usr/include/libgen.h:61:21: note: expanded from macro 'basename'
  basename)(x)
/usr/include/sys/cdefs.h:325:2: note: expanded from macro '__generic'
        _Generic(expr, t: yes, default: no)

(In the same context Autoconf does not request a specific C standard
from Clang, so it happens to use C17 and there is no warning.)

Type-generic expressions support in C99 mode seems to be a quirk of
Clang that cannot be disabled and is harmless in this context, so
introduce and use another pair of diagnostic control macros (for Clang
only) to squelch the warnings.

While at it, study the reason for _Generic use in /usr/include/libgen.h
and realize that tcpdump.c still assumes the behaviour before FreeBSD
12.0.  Add two temporary buffers around basename() and dirname() calls
to get consistent results regardless of which FreeBSD version it is.

Remove the last remaining exemption rule.

(cherry picked from commit 780f86b43c33d3f0fd0c067e2c1847e2a6360dae)

3 months agoFix auto-enabling of Capsicum on FreeBSD with Autoconf. [skip appveyor]
Denis Ovsienko [Tue, 3 Aug 2021 23:20:36 +0000 (00:20 +0100)] 
Fix auto-enabling of Capsicum on FreeBSD with Autoconf. [skip appveyor]

Even after commit 6393bb6 --with-sandbox-capsicum didn't work entirely
as documented, as it defaulted to disabled:

checking whether to sandbox using capsicum... no
checking whether to sandbox using Casper library... no

Get the test condition right so it does what it says:

checking sys/capsicum.h usability... yes
checking sys/capsicum.h presence... yes
checking for sys/capsicum.h... yes
checking for cap_enter... yes
checking for cap_rights_limit... yes
checking for cap_ioctls_limit... yes
checking for openat... yes
checking for cap_init in -lcasper... yes
checking for cap_gethostbyaddr in -lcap_dns... yes
checking whether to sandbox using capsicum... yes
checking whether to sandbox using Casper library... yes

(cherry picked from commit ac23514a0cc7a08eec383aac352fa3f7d39dec2c)

3 months agoSquelch a warning with Capsicum enabled. [skip appveyor]
Denis Ovsienko [Tue, 3 Aug 2021 22:38:48 +0000 (23:38 +0100)] 
Squelch a warning with Capsicum enabled. [skip appveyor]

The Capsicum workaround I added in commit 706c79e causes a side effect
on FreeBSD 11.4, 12.2 and 13.0 with local libpcap when Capsicum is
enabled, that is, in CMake builds (Capsicum detection is broken in
Autoconf builds, as it turns out).  Add a workaround for the side effect
as well and get rid of another warning and respective exemption:

tcpdump.c:2286:3: warning: implicit declaration of function 'bpf_dump'
  is invalid in C99 [-Wimplicit-function-declaration]

(cherry picked from commit 51f9c3b947eac89254c4e3662902487e0844a699)

3 months agoCMake: Fix EXTRA_CFLAGS after commit cae0c65. [skip appveyor]
Denis Ovsienko [Tue, 3 Aug 2021 22:25:02 +0000 (23:25 +0100)] 
CMake: Fix EXTRA_CFLAGS after commit cae0c65. [skip appveyor]

Same as in libpcap.

(cherry picked from commit bbeedf4f477ff85a0563ae514517798e1022c3ff)

3 months agoDefine PRINTFLIKE_FUNCPTR() exactly for XL C. [skip appveyor]
Denis Ovsienko [Tue, 3 Aug 2021 17:23:13 +0000 (18:23 +0100)] 
Define PRINTFLIKE_FUNCPTR() exactly for XL C. [skip appveyor]

XL C full version consists of 4 numbers.  Introduce an additional macro
for testing the two least significant numbers.  Using the fix lists
published by IBM, tell XL C 16.1 that has the bug interpreting the
__format__ attribute of a function pointer from XL C 16.1 that has not.
Rejig the #if block to make it easier to follow.

(cherry picked from commit 66e1377aa133bf83ecf92679a53f7d0c54efc445)

3 months agoCI: Get randomness right in mktempdir_diy(). [skip ci]
Denis Ovsienko [Tue, 3 Aug 2021 14:36:31 +0000 (15:36 +0100)] 
CI: Get randomness right in mktempdir_diy(). [skip ci]

Same as in tcpslice.

(cherry picked from commit 0623e614865a40639ec5c6f081079d09efdeff2c)

3 months agoCI: Put a misplaced comment right in build.sh. [skip ci]
Denis Ovsienko [Tue, 3 Aug 2021 14:31:54 +0000 (15:31 +0100)] 
CI: Put a misplaced comment right in build.sh. [skip ci]

The script both assigns and uses TCPDUMP_BIN, so it is the export line
that is purposed for TESTrun rather than the variable assignment.

(cherry picked from commit e8be4e64cdab05154bf09aa2680772e38b4de6fe)

3 months agoconfigure: special-case macOS /usr/bin/pcap-config as we do in CMake.
Guy Harris [Tue, 3 Aug 2021 19:58:34 +0000 (12:58 -0700)] 
configure: special-case macOS /usr/bin/pcap-config as we do in CMake.

macOS's /usr/bin/pcap-config is incorrectly generated - pcap-config
--cflags includes -I/usr/local/include and pcap-config --libs includes
-L/usr/local/lib, even though it's the pcap-config file for the libpcap
that comes with the OS and should omit those.

(cherry picked from commit fc240c64fb2070d37ccc2a4a2c2d998c4055f4f4)

3 months agoMove capdns from tcpdump.c to addrtoname.c.
Denis Ovsienko [Sun, 1 Aug 2021 23:32:46 +0000 (00:32 +0100)] 
Move capdns from tcpdump.c to addrtoname.c.

Address the warning below (specific to a few versions of Clang, CMake
and FreeBSD) and update the exemption rule comment in build.sh.

tcpdump.c:244:16: warning: no previous extern declaration for non-static
  variable 'capdns' [-Wmissing-variable-declarations]

(cherry picked from commit e5bf4ceec7bf1a5a08852ad3a449a5f259f9bed5)

3 months agoCMake: Handle EXTRA_CFLAGS w/o add_compile_options(). [skip ci]
Denis Ovsienko [Sat, 31 Jul 2021 20:35:17 +0000 (21:35 +0100)] 
CMake: Handle EXTRA_CFLAGS w/o add_compile_options(). [skip ci]

Same as in libpcap commit 29d7856.

(cherry picked from commit cae0c6501350fe1d1742211014530a60c2e91f71)

3 months agoLose two unused macros in diag-control.h. [skip ci]
Denis Ovsienko [Sat, 31 Jul 2021 20:04:11 +0000 (21:04 +0100)] 
Lose two unused macros in diag-control.h. [skip ci]

(cherry picked from commit d423316ce13c268760a401d5d19e38dd59278f9e)

3 months agoCI: Explain useful side effects of "-D" and "-J". [skip ci]
Denis Ovsienko [Fri, 30 Jul 2021 15:20:34 +0000 (16:20 +0100)] 
CI: Explain useful side effects of "-D" and "-J". [skip ci]

(cherry picked from commit 74ab2face01e4ee9966f45ee87a80174b098cdd3)

3 months agoCMake: Add a way to request -Werror and equivalents.
Denis Ovsienko [Fri, 30 Jul 2021 09:12:59 +0000 (10:12 +0100)] 
CMake: Add a way to request -Werror and equivalents.

As it turns out, most FreeBSD/CMake tcpdump builds were emitting some
warnings.  This was difficult to notice because make returned success
regardless of the warnings because the compiler never received -Werror
because there was no way to tell CMake to append any compiler flags at
the build time, but not at the buildsystem generation time.  In other
words, the command "make CFLAGS=-Werror" had the same effect as just
"make".

Implement the desired behaviour with "cmake -DEXTRA_CFLAGS='xyz'" and
set the variable in build.sh when and as required.  Reword the comment
for clarity and define two known exemptions.

(cherry picked from commit 7880ad999f1a3d6c3aca4bd31ce90755c924f947)

3 months agoCI: Port recent improvements from tcpslice. [skip appveyor]
Denis Ovsienko [Fri, 30 Jul 2021 08:44:04 +0000 (09:44 +0100)] 
CI: Port recent improvements from tcpslice. [skip appveyor]

Introduce TCPDUMP_TAINTED, improve OS and compiler identification, print
matrix progress to stderr.

(cherry picked from commit 9b40c0b7675a2f361dc8cfdb01abeba1cb32092c)

3 months agoAddress some issues with XL C on Linux/POWER9.
Denis Ovsienko [Tue, 27 Jul 2021 13:06:28 +0000 (14:06 +0100)] 
Address some issues with XL C on Linux/POWER9.

XL C 16.1.1 Community Edition for Linux generated three warnings for
every file:

In file included from ./tcpdump.c:155:
./netdissect.h:254:8: warning: 1540-2990 The attribute
"__attribute__((format(printf, 2, 3)))" is not supported. The
      attribute is ignored.
                     PRINTFLIKE_FUNCPTR(2, 3);
                     ^
./netdissect.h:259:10: warning: 1540-2990 The attribute
" __attribute__((format(printf, 3, 4)))" is not supported.
      The attribute is ignored.
                                     PRINTFLIKE_FUNCPTR(3, 4);
                                     ^
./netdissect.h:263:9: warning: 1540-2990 The attribute
" __attribute__((format(printf, 2, 3)))" is not supported. The
      attribute is ignored.
                      PRINTFLIKE_FUNCPTR(2, 3);
                      ^

As it turns out, this is a bug in the compiler. In compiler-tests.h
update ND_IS_AT_LEAST_XL_C_VERSION() to tell newer XL C versions. In
funcattrs.h exempt XL C 16.1 from PRINTFLIKE_FUNCPTR().

In the course of preparing these changes notice that XL C uses the Clang
block in diag-control.h (XL C mimics both Clang and GCC to some extent),
although the behaviour is different between the two compilers. Add a new
block for XL C there.

In build_common.sh add more comments to explain XL C quirks and detect
XL C for Linux too so it receives the right CFLAGS. Update CHANGES to
mention this and earlier improvements.

(cherry picked from commit c3c949e98e9d046a2017a122ba869c89329acdd1)

3 months agoCI: Make MATRIX_CC loop the outermost.
Denis Ovsienko [Mon, 26 Jul 2021 15:27:28 +0000 (16:27 +0100)] 
CI: Make MATRIX_CC loop the outermost.

This way if an iteration includes a local libpcap, the latter is always
compiled with the same CC. This works around odd linking problems on
AIX 7 and Solaris 9 and 10 when one C compiler is GCC and the other is
the vendor's compiler, for example:

* GCC used for libpcap, XL C used for tcpdump:
ld: 0711-317 ERROR: Undefined symbol: .__udivdi3
ld: 0711-317 ERROR: Undefined symbol: .__umoddi3

* GCC used for libpcap, Sun C used for tcpdump:
Undefined                       first referenced
 symbol                             in file
__ctzsi2                            ../libpcap/libpcap.a(optimize.o)
__udivdi3                           ../libpcap/libpcap.a(sf-pcapng.o)
__umoddi3                           ../libpcap/libpcap.a(sf-pcapng.o)
ld: fatal: Symbol referencing errors. No output written to conftest

Similar issues associated with a mix of GCC and Clang had happened on
FreeBSD/AArch64 earlier (addressed in tcpslice commit 75b7771), and
still seem to happen on OpenBSD/AArch64. Hopefully removing the
toolchain mix from the problem space will make it easier to fix other
problems.

(cherry picked from commit d3312a6438748730f40e4fd3cbd0dfc56ae16c54)

3 months agoCI: Print dynamic dependencies early. [skip ci]
Denis Ovsienko [Mon, 26 Jul 2021 14:33:17 +0000 (15:33 +0100)] 
CI: Print dynamic dependencies early. [skip ci]

Call print_so_deps() just after "make install", so if dynamic linking
has failed for some reason, the failure to run tcpdump binary will not
prevent printing the details. Lose "tcpdump --version" because version
information is a part of "tcpdump -h" output.

-- Installing: /tmp/tcpdump_build_matrix.XXyKaiEo/bin/tcpdump
-- Set runtime path of "/tmp/tcpdump_build_matrix.XXyKaiEo/bin/tcpdump" to ""
-- Installing: /tmp/tcpdump_build_matrix.XXyKaiEo/share/man/man1/tcpdump.1
$ /tmp/tcpdump_build_matrix.XXyKaiEo/bin/tcpdump --version
ld.so.1: tcpdump: fatal: libpcap.so.1: open failed: No such file or directory

(cherry picked from commit b1dca9b165677e170a9ed65ae5087de8a122df0d)

3 months agoCI: GCC can appear as "egcc" on OpenBSD. [skip ci]
Denis Ovsienko [Mon, 26 Jul 2021 11:46:33 +0000 (12:46 +0100)] 
CI: GCC can appear as "egcc" on OpenBSD. [skip ci]

(cherry picked from commit 3f093722ef7efd55c2b3c9bfa2fd17fe54944b6b)

3 months agoSquelch a noreturn warning on AIX. [skip ci]
Denis Ovsienko [Mon, 26 Jul 2021 11:01:00 +0000 (12:01 +0100)] 
Squelch a noreturn warning on AIX. [skip ci]

GCC 8.3.0 on AIX 7.1 produced a warning for every file that has a call
to nd_trunc_longjmp():

In file included from ./cpack.c:39:
./extract.h: In function 'nd_trunc_longjmp':
./extract.h:586:1: warning: 'noreturn' function does return

As far as longjmp(3) man page and <setjmp.h> header go, longjmp() is as
noreturn in AIX as everywhere else, but not in a way that GCC can tell.

Disabling -Wsuggest-attribute=noreturn and -Wmissing-noreturn had no
apparent effect, so instead of using diag-control.h add an infinite loop
on AIX to squelch the warning.

(cherry picked from commit b7401ffd865af51060604b7eb76ff593397293d6)

3 months agoCI: Refine C compilers handling. [skip appveyor]
Denis Ovsienko [Sun, 25 Jul 2021 22:06:11 +0000 (23:06 +0100)] 
CI: Refine C compilers handling. [skip appveyor]

In build_common.sh add minimal heuristics to print_cc_version() to help
it run the right command; add cc_id() and cc_werr_cflags() to pick the
right CFLAGS for the current compiler instead of the previously
hard-coded "-Werror". Add some comments.

In build.sh remove the CFLAGS exemptions for AIX and Solaris 9 builds,
which are in a better shape now and can complete specific subsets of the
full matrix without a warning. Set CFLAGS from cc_werr_cflags() to make
the best effort to catch as many warnings as possible. Let's see how well
that works.

(cherry picked from commit cdc3bc2359dc214dfedf5fc5dec4712058af7d33)

3 months agoMend "make check" on Solaris 9 (Autoconf only).
Denis Ovsienko [Sun, 25 Jul 2021 13:29:02 +0000 (14:29 +0100)] 
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.

(cherry picked from commit fbd44158e0d5e6bb0c9b05671f702ebcf68cc56d)

3 months agoconfigure: use AC_COMPILE_IFELSE() and AC_LANG_SOURCE() for testing flags.
Guy Harris [Sun, 25 Jul 2021 10:02:54 +0000 (03:02 -0700)] 
configure: use AC_COMPILE_IFELSE() and AC_LANG_SOURCE() for testing flags.

That lets us completely control the program that's compiled with the
compiler flag we're testing, so we can make it a minimal program that
uses only prototype declarations and that therefore won't generate
warnings with some -W flags, e.g. -Wold-style-definition, and thus won't
falsely report those flags as unsupported.

(cherry picked from commit a917017bc0e68fa600e5d5fd1a724456053f9e4b)

3 months agoconfigure: use ac_c_werror_flag to force unknown compiler flags to fail.
Guy Harris [Sun, 25 Jul 2021 09:22:42 +0000 (02:22 -0700)] 
configure: use ac_c_werror_flag to force unknown compiler flags to fail.

It's not a documented feature, but it's what the documented
AC_LANG_WERROR has used for 13 years, and there's no push/pop mechanism
for AC_LANG_WERROR, so you can't ensure that "fail even on warnings"
will be applied *only* in AC_LBL_CHECK_COMPILER_OPT(), as that's what we
want.  (If we can make sure that *no* compiler tests will produce
warnings, except for the ones we *want* to fail if they produce
warnings, we could just do AC_LANG_WERROR, but that might be tricky to
ensure in the general case.)

We do this because not all compilers have a command-line flag to force
all warnings, *including* warnings from unknown commad-line flags (I'm
looking at *you* IBM XL C!), so we have to have the test check to make
sure no warnings are produced (which, for AC_TRY_COMPILE(), means
"nothing is written to the standard output").

In addition, AC_TRY_COMPILE() generates a return; don't add one:

If we pass [return 0] to AC_TRY_COMPILE(), the test program it compiles
has two "return 0;" statements in a row, and one of the -W flags we
tests reports a warning for that.

We were testing whether a -W flag is supported by checking the standard
error of the compiler to see if *any* error/warning messages are
generated, and treating the flag as unsupported if any are, that meant
that -Wunreachable-code-return was be treated as unsupported even though
it *is* supported.

This should fix that.  (I'm so glad autoconf makes this all so difficult
to do correctly....)

(cherry picked from commit 95ae3ed835f5b3f285bef75fe7913a58df9461aa)

3 months agoFixup the previous commit for GCC. [skip ci]
Denis Ovsienko [Sat, 24 Jul 2021 10:43:25 +0000 (11:43 +0100)] 
Fixup the previous commit for GCC. [skip ci]

Apparently, it does not like pragmas in the middle of a statement:

./missing/getopt_long.c: In function 'getopt_internal':
./missing/getopt_long.c:572:3: error: 'else' without a previous 'if'

(cherry picked from commit 34fd411f222dd93868ae677dbe8ae82d09f9f199)

3 months agoSuppress "casting away const" warnings in missing/getopt_long.c.
Guy Harris [Sat, 24 Jul 2021 08:51:02 +0000 (01:51 -0700)] 
Suppress "casting away const" warnings in missing/getopt_long.c.

It's explicitly cheating in some places; just cast away the warnings.

Add a Clang version testing macro to compiler-tests.h.

Move the diagnostic control #defines from netdissect-stdinc.h to
diag-control.h, libpcap-style, so that they can be used by code that
doesn't use (or need) netdissect-stdinc.h.  This also means that we can
limit the inclusion of diag-control.h, and the definition of those

Do them more libpcap-style, with separate DIAG_OFF/DIAG_ON pairs for
particular issues, rather than having DIAG_OFF() and DIAG_ON() macros
that take -W option names as arguments; that way, if we need to define
them for compilers that don't have the GCC/Clang syntax for those
pragmas, e.g. MSVC, we can do so.

(cherry picked from commit 39f09d68ce7ebe9e229c9bf5209bfc30a8f51064)

3 months agoCI: Add missing SC2006 squelch directives. [skip ci]
Denis Ovsienko [Fri, 23 Jul 2021 13:05:18 +0000 (14:05 +0100)] 
CI: Add missing SC2006 squelch directives. [skip ci]

(cherry picked from commit c8e8e57d057ac6edd098ffbf11cd661099fc43c2)

3 months agoCI: Import recent build matrix improvements. [skip appveyor]
Denis Ovsienko [Fri, 23 Jul 2021 00:52:50 +0000 (01:52 +0100)] 
CI: Import recent build matrix improvements. [skip appveyor]

Start using build_common.sh, make default assignments early and
uniformly, use Solaris-compatible command substitution and exports,
install bc on linux-amd64, deduplicate and reformat some long commands.
Run "make -s" without CFLAGS=-Werror when warnings are expected.

This implements initial support for AIX and Solaris in the tcpdump build
matrix scripts.

* AIX 7.1
M4='/opt/freeware/bin/m4' \
MATRIX_CC='gcc' \
MATRIX_CMAKE=no \
MATRIX_BUILD_LIBPCAP=yes \
./build_matrix.sh

* Solaris 9
MATRIX_CC=gcc \
MATRIX_CMAKE=no \
MATRIX_BUILD_LIBPCAP=no \
./build_matrix.sh

* Solaris 10 and 11
MATRIX_CC='gcc' \
MATRIX_CMAKE=no \
./build_matrix.sh

(cherry picked from commit 507a4c91b5bee98f64656afe9fbe6d314dbff21a)

3 months agoAdapt TESTrun constants for older Perl. [skip ci]
Denis Ovsienko [Fri, 23 Jul 2021 00:24:22 +0000 (01:24 +0100)] 
Adapt TESTrun constants for older Perl. [skip ci]

Solaris 9 has Perl 5.6.1, which does not support constant declaration
using a hash reference:

$ make check
./tests/TESTrun
Constant name 'HASH(0x2d8f0)' has invalid characters at ./tests/TESTrun
line 24
BEGIN failed--compilation aborted at ./tests/TESTrun line 24.
*** Error code 255
make: Fatal error: Command failed for target `check'

Declare one constant at a time to work around that and get "make check"
to start running tests (18 of which fail, but that's another issue).

(cherry picked from commit 85a27898f6b43579a108d995a5efad341f404c75)

3 months agoImport Autoconf/make and "make releasetar" fixes. [skip ci]
Denis Ovsienko [Thu, 22 Jul 2021 17:27:08 +0000 (18:27 +0100)] 
Import Autoconf/make and "make releasetar" fixes. [skip ci]

These have been tested in tcpslice and libpcap.

(cherry picked from commit 789b35b5981b9af915af44f35f6ce683ea0b1801)

3 months agoCI: Run "make releasetar" regardless of the OS.
Denis Ovsienko [Sun, 18 Jul 2021 00:04:13 +0000 (01:04 +0100)] 
CI: Run "make releasetar" regardless of the OS.

Same as in tcpslice.

(cherry picked from commit 166cdc3dfb08744ff3d15a583ca432b3a548d4ff)

3 months agoCI: Add back running tcpdump -J/-L and capture, now with Cirrus VMs.
Francois-Xavier Le Bail [Wed, 7 Jul 2021 16:37:12 +0000 (18:37 +0200)] 
CI: Add back running tcpdump -J/-L and capture, now with Cirrus VMs.

The Cirrus virtual machines are throwaway.

Revert partially f5739ad4cab362afdebbf3af588e9f05e0e0009b.

(cherry picked from commit 24f217998d866e9199de829efa2bae432402bcd7)

3 months agoCI: Get Travis CI vestige sorted in build.sh.
Denis Ovsienko [Mon, 5 Jul 2021 18:37:04 +0000 (19:37 +0100)] 
CI: Get Travis CI vestige sorted in build.sh.

Compiling user-provided source code and running the resulting binary
with sudo was a security problem, thus instead of fixing two no-op
blocks remove them altogether. If anyone later needs to debug features
that require higher privileges, they will need to come up with a better
solution. Simplify the debug output test condition and rephrase the
associated comment for clarity.

(cherry picked from commit f5739ad4cab362afdebbf3af588e9f05e0e0009b)

3 months agoCI: List shared libraries on more OSes.
Denis Ovsienko [Mon, 5 Jul 2021 17:22:23 +0000 (18:22 +0100)] 
CI: List shared libraries on more OSes.

Running ldd on Linux only originates from the Travis CI setup, where the
OS was either Linux or macOS. However, ldd is available in BSD systems
too, and macOS seems to have its own tool for the same job.

(cherry picked from commit d56f0615004ad251a430623a34268a2ce72ba8a2)

3 months agoospf: add support bit Nt RFC3101
ckishimo [Fri, 22 Jan 2021 09:45:24 +0000 (10:45 +0100)] 
ospf: add support bit Nt RFC3101

(cherry picked from commit c86534460a4e0cc2516b96f67aabd8b5ea4e9d16)

3 months agolwres: Fix a length check
Francois-Xavier Le Bail [Mon, 27 Sep 2021 13:43:32 +0000 (15:43 +0200)] 
lwres: Fix a length check

This fix some inconsistent outputs clang versus gcc in 32 bits mode.

Add a test file.

(cherry picked from commit fd409921d94a0aff7804df31515fa42b675118b5)

6 months agoCI: Lose the output folding props.
Denis Ovsienko [Mon, 5 Jul 2021 11:09:59 +0000 (12:09 +0100)] 
CI: Lose the output folding props.

Same as in libpcap.

(cherry picked from commit 35a8fc576dcade07a772e5c63ba9412b545d90bd)

6 months agoCI: Switch from bash to POSIX shell.
Denis Ovsienko [Mon, 5 Jul 2021 10:59:03 +0000 (11:59 +0100)] 
CI: Switch from bash to POSIX shell.

Same as in libpcap.

(cherry picked from commit 63ea6b5d479c70a8bfb15052885d08483a29d217)

6 months agoCI: Simplify some Coverity Scan props.
Denis Ovsienko [Mon, 5 Jul 2021 10:32:03 +0000 (11:32 +0100)] 
CI: Simplify some Coverity Scan props.

Same as in libpcap.

(cherry picked from commit 59ddbc3fd41600c293c05cd75b3bdc80ff8eb18f)

6 months agoAppVeyor: Update Npcap SDK to 1.10
Francois-Xavier Le Bail [Sun, 4 Jul 2021 07:40:42 +0000 (09:40 +0200)] 
AppVeyor: Update Npcap SDK to 1.10

(cherry picked from commit 4762c8094d387a5da4d3be92f4381a2f8082dae8)

6 months agoJuniper: Add some bounds checks
Francois-Xavier Le Bail [Wed, 23 Jun 2021 05:55:34 +0000 (07:55 +0200)] 
Juniper: Add some bounds checks

Avoid to have p (current pointer on packet data) > ndo->ndo_snapend
in isoclns_print() in some cases.

Define ND_LONGJMP_FROM_TCHECK.
Remove some trunc labels.

(cherry picked from commit 880b867ee73ae757faebbab13213c7d4079222a5)

6 months agoUpdate version to 4.99.2-PRE-GIT
Francois-Xavier Le Bail [Wed, 23 Jun 2021 12:20:28 +0000 (14:20 +0200)] 
Update version to 4.99.2-PRE-GIT

7 months agobump version and update CHANGES tcpdump-4.99.1
Michael Richardson [Wed, 9 Jun 2021 19:24:12 +0000 (15:24 -0400)] 
bump version and update CHANGES

7 months agoautoconf: Find a local libpcap even with rcX directory suffix
Francois-Xavier Le Bail [Mon, 7 Jun 2021 19:01:15 +0000 (21:01 +0200)] 
autoconf: Find a local libpcap even with rcX directory suffix

(cherry picked from commit f91ef58f2f904e6e7bcbef7d184479cb89c6d360)

7 months agoAppVeyor: Update Npcap SDK to 1.07
Francois-Xavier Le Bail [Thu, 3 Jun 2021 11:14:23 +0000 (13:14 +0200)] 
AppVeyor: Update Npcap SDK to 1.07

(cherry picked from commit 7eb602af5925c85bee9239a59196108d3cfaf7e7)

7 months agoUse quoted include netdissect-stdinc.h instead of angle-bracketed one
Francois-Xavier Le Bail [Wed, 2 Jun 2021 09:22:46 +0000 (11:22 +0200)] 
Use quoted include netdissect-stdinc.h instead of angle-bracketed one

Same as other printers.

(cherry picked from commit c39eb094791a3553b2a77e03ded78f50bc3ac4d2)

7 months agoMerge Readme.Win32 into doc/README.Win32.md. [skip ci]
Guy Harris [Mon, 31 May 2021 11:47:47 +0000 (04:47 -0700)] 
Merge Readme.Win32 into doc/README.Win32.md. [skip ci]

We should only have one "how to build on Windows" file.

(cherry picked from commit c7e9212a017ba0bea0abfd7d4b471c0082de8864)

7 months agoMakefile.in: Add the shellcheck target
Francois-Xavier Le Bail [Tue, 1 Jun 2021 07:44:41 +0000 (09:44 +0200)] 
Makefile.in: Add the shellcheck target

Run shellcheck on the build.sh and the build_matrix.sh scripts.
(using 'gcc' format: GCC compatible output. See the shellcheck man page)

[skip ci]

(cherry picked from commit 657d672cb672b80d4cd7a18a6f746968d9d44807)

7 months agobuild_matrix.sh: Fix a shellcheck warning
Francois-Xavier Le Bail [Mon, 31 May 2021 13:03:09 +0000 (15:03 +0200)] 
build_matrix.sh: Fix a shellcheck warning

The warning was:
Use "${var:?}" to ensure this never expands to /* . [SC2115]

(cherry picked from commit 815919247bf40f65777cae4b4eb95f78b4e28917)

7 months agobuild.sh: Disable a shellcheck error
Francois-Xavier Le Bail [Mon, 31 May 2021 13:01:44 +0000 (15:01 +0200)] 
build.sh: Disable a shellcheck error

We need the $@ expansion.

The error was:
Double quote array expansions to avoid re-splitting elements. [SC2068]

(cherry picked from commit 5abf27529db8ad8bcadc31ebe5eadc4de036c898)

7 months agoMakefile.in: Add the build for release candidates
Francois-Xavier Le Bail [Sun, 30 May 2021 08:40:53 +0000 (10:40 +0200)] 
Makefile.in: Add the build for release candidates

It adds rcX suffix to the version.
This avoid to manually update 'VERSION' and 'configure'.
Same as for libpcap.

(cherry picked from commit 4356f99512f7a4fd6ff8780b1e75aa102aaf3402)

7 months agoUpdate config.{guess,sub}, timestamps 2021-01-25,2021-03-10
Francois-Xavier Le Bail [Thu, 27 May 2021 15:26:38 +0000 (17:26 +0200)] 
Update config.{guess,sub}, timestamps 2021-01-25,2021-03-10

From repository git://git.savannah.gnu.org/config.git

(cherry picked from commit f9f128373b34d4448471c9c8bc7e1bea1e919ca5)

7 months agoHaiku is a supported platform. [skip ci]
Denis Ovsienko [Thu, 6 May 2021 09:07:39 +0000 (10:07 +0100)] 
Haiku is a supported platform. [skip ci]

Haiku R1/Beta 2 includes tcpdump and libpcap, even though these seem to
disregard any specified pcap filter expressions.

~> uname -a
Haiku shredder 1 hrev54154+111 Jun  7 2020 07:16 x86_64 x86_64 Haiku
~> tcpdump --version
tcpdump version 4.9.2
libpcap version 1.8.1

(cherry picked from commit 16c95291bde1c04a6e3c31da3b12c3b592d09968)

7 months agoRemove PLATFORMS (was merged into README.md)
Francois-Xavier Le Bail [Sun, 25 Apr 2021 18:37:28 +0000 (20:37 +0200)] 
Remove PLATFORMS (was merged into README.md)

[skip ci]

(cherry picked from commit a5837ddd83efb74c0a423f091ec8ca2cfa8851e5)

7 months agoRefine README.md and some related files. [skip ci]
Denis Ovsienko [Fri, 16 Apr 2021 17:25:11 +0000 (18:25 +0100)] 
Refine README.md and some related files. [skip ci]

Lose the README symlink, it was a bad idea of mine to add it in the
first place as it made the packaging problem space bigger, not smaller.

Remove two CI badges at the top of README.md. One badge was stale
anyway, and the other does not represent the current CI configuration,
which is bigger, changes frequently and fits the web-site much better.

Remove the reference to ITA, it has been down for quite a while, it
looks like it won't re-emerge this time.

Merge PLATFORMS into README.md.

(cherry picked from commit e3a00d340c8707b178b0cce017e009cfaafdd22d)

7 months agoRefine Markdown in README.md. [skip appveyor]
Denis Ovsienko [Fri, 5 Feb 2021 14:25:11 +0000 (14:25 +0000)] 
Refine Markdown in README.md. [skip appveyor]

Move "by TTG" to the main header and eliminate a few duplicate "by"
sentences. Update a CI badge to use the travis-ci.com URLs. Make the
security note bold to help more people actually get it. Change the git
URL to github.com to be consistent with libpcap. Add and refine a few
headers. Add and improve hyperlink formatting in a few places. Lose a
few excess generic sentences. Fixup some minor editorial issues. Fence
the "from LBL" boilerplate, move it to the bottom of the dedicated
section and eliminate a few duplicate "from" sentences.

Skip only some CI on this occasion, so Travis CI can transfer the build
history from travis-ci.org to travus-ci.com and complete the migration.

(cherry picked from commit 50c0ec867c9fb34707060a3048a5dd2ae398da6a)

7 months agoICMP: Fix a typo in a comment.
Denis Ovsienko [Thu, 7 Jan 2021 01:07:46 +0000 (01:07 +0000)] 
ICMP: Fix a typo in a comment.

(cherry picked from commit c518a9aab149da1a6b83c0cbeddaff5265d05dcb)

7 months agoRemove the no more used nd_print() function
Francois-Xavier Le Bail [Sat, 9 Jan 2021 13:07:53 +0000 (14:07 +0100)] 
Remove the no more used nd_print() function

The function to use now is: nd_printjnp().
(Added by commit 635e3cc92b72ca048a6b5b89b883980e4e1b4bdc)

(cherry picked from commit f867bc9f40b4ce00e08fa6377bbb7d74719b9313)

7 months agoZephyr: Update 'length' type to unsigned
Francois-Xavier Le Bail [Sat, 22 May 2021 07:41:31 +0000 (09:41 +0200)] 
Zephyr: Update 'length' type to unsigned

It is unsigned in the calling function udp_print().

(cherry picked from commit 29973d83e8cecbb3bc940af216f6bef2376f39c5)

7 months agoFix a typo
Francois-Xavier Le Bail [Sat, 22 May 2021 12:16:05 +0000 (14:16 +0200)] 
Fix a typo

[skip ci]

(cherry picked from commit 59d322719785f4bc2a00bc4c2a35f93efc82f189)

7 months agoRecommend using the upstream CI in CONTRIBUTING. [skip ci]
Denis Ovsienko [Tue, 11 May 2021 22:41:31 +0000 (23:41 +0100)] 
Recommend using the upstream CI in CONTRIBUTING. [skip ci]

CI configuration is a running target, and much of it works on Buildbot,
in which pull requests are the only practicable option for 3rd parties.

(cherry picked from commit f8491f77ac4d22b32cdf9d89540112c2bb037ffb)

7 months agoBGP: Use a macro for repeated identical sizeof()
Francois-Xavier Le Bail [Wed, 26 May 2021 09:06:55 +0000 (11:06 +0200)] 
BGP: Use a macro for repeated identical sizeof()

[skip ci]

(cherry picked from commit c0335764f437b631c645e00e4e3c7be075bbb4e2)

7 months agoFrame Relay: make the buffer big enough for the biggest message.
Guy Harris [Wed, 26 May 2021 06:25:41 +0000 (23:25 -0700)] 
Frame Relay: make the buffer big enough for the biggest message.

(cherry picked from commit df2dc59f6c0bf217afdbddbd178d3114a9edc2b5)

7 months agoCHANGES: list the most recent change. [skip ci]
Guy Harris [Wed, 26 May 2021 05:28:09 +0000 (22:28 -0700)] 
CHANGES: list the most recent change.  [skip ci]

(cherry picked from commit bf8bf8de486e8aa5771bccc0753b56d91df8f3d0)

7 months agoFrame Relay: have q922_string() handle errors better.
Guy Harris [Wed, 26 May 2021 05:26:48 +0000 (22:26 -0700)] 
Frame Relay: have q922_string() handle errors better.

Have it return a string indicating an error, rather than a null string.

(cherry picked from commit 51bc4bffb849bd323fcff9a03b8b5492885fe37a)

7 months agoCHANGES: update with additional changes in the 4.99 branch. [skip ci]
Guy Harris [Wed, 26 May 2021 00:53:25 +0000 (17:53 -0700)] 
CHANGES: update with additional changes in the 4.99 branch. [skip ci]

Move some from the 5.0 list to the 4.99 list.

(cherry picked from commit ec3195c37396c003d4ed90c057fd88ba8cc81905)

7 months agoARP: fix overwrites of static buffer in q922_string().
Guy Harris [Tue, 25 May 2021 22:22:49 +0000 (15:22 -0700)] 
ARP: fix overwrites of static buffer in q922_string().

Don't call GET_LINKADDR_STRING() twice in a given ND_PRINT() call.

Should address another problem in GitHub issue #919.

(cherry picked from commit e72a7ba0a21f1c1a0fc8472542bffa69abbf44b9)

7 months agoBGP: Fix overwrites of global 'astostr' temporary buffer
Francois-Xavier Le Bail [Tue, 25 May 2021 16:23:19 +0000 (18:23 +0200)] 
BGP: Fix overwrites of global 'astostr' temporary buffer

Remove the global 'astostr'.

Use a local 'astostr' in the functions that use it.

This should fix GitHub issue #919.

Moreover:
Rename 'asbuf' to 'astostr'.

(cherry picked from commit cf6c3fb2ad11e3ce94401b4371d91def79934310)

8 months agoIEEE 802.15.4: Add a bounds check
Francois-Xavier Le Bail [Fri, 14 May 2021 18:34:35 +0000 (20:34 +0200)] 
IEEE 802.15.4: Add a bounds check

This avoids to have cp (current pointer on packet data) > ndo->ndo_snapend
in hex_and_ascii_print(), via ndo_default_print(), via ND_DEFAULTPRINT(),
in some cases.

(cherry picked from commit d76dc9f90ab9c6188063696668b6f2e749df7911)

8 months agoIEEE 802.15.4: Add some bounds checks
Francois-Xavier Le Bail [Tue, 11 May 2021 10:21:28 +0000 (12:21 +0200)] 
IEEE 802.15.4: Add some bounds checks

This avoids to have cp (current pointer on packet data) > ndo->ndo_snapend
in hex_and_ascii_print(), via ndo_default_print(), via ND_DEFAULTPRINT(),
in some cases.

(cherry picked from commit 346ea98e51a8d50acbbe010f4b39b098d34caa2f)

8 months agoZEP: Add a bounds check
Francois-Xavier Le Bail [Sun, 9 May 2021 17:48:01 +0000 (19:48 +0200)] 
ZEP: Add a bounds check

This avoids to have cp (current pointer on packet data) > ndo->ndo_snapend
in hex_and_ascii_print(), via ndo_default_print(), via ND_DEFAULTPRINT(),
in some cases.

(cherry picked from commit 6f245276a2a24d673f2919e33476191781e20499)

8 months agoman: Update DNS sections
Francois-Xavier Le Bail [Sun, 25 Apr 2021 18:05:45 +0000 (20:05 +0200)] 
man: Update DNS sections

The DNS transactions also take place over TCP.

Harmonize text: s/not including/excluding/ like in Name Server Responses
section.

[skip ci]

(cherry picked from commit eac90e30d2d35d12f8b3305dce86e2afb313c99f)

8 months agoEthernet: Add a bounds check
Francois-Xavier Le Bail [Thu, 6 May 2021 11:39:10 +0000 (13:39 +0200)] 
Ethernet: Add a bounds check

Avoid to have p (current pointer on packet data) > ndo->ndo_snapend
in isoclns_print() in some cases.

Moreover:
Add a "FIXME" comment.

(cherry picked from commit 7b7b84716e604abd8bd92cee75e6385cab6ce3dc)

8 months agoReplace ND_TCHECK_/memcpy() pairs with GET_CPY_BYTES().
Guy Harris [Wed, 6 Jan 2021 02:01:26 +0000 (18:01 -0800)] 
Replace ND_TCHECK_/memcpy() pairs with GET_CPY_BYTES().

For BGP, this eliminates some cases where routines return -1 on
truncation; clean up after that.

This also means that some memcpy()s get replaced by UNALIGNED_MEMCPY(),
which may fix some issues on processors that don't support unaligned
accesses.

(cherry picked from commit f853e73acf39658125ce42861e49ce4a181611d3)

9 months agoCirrus CI: Bump FreeBSD 13.0 up to the release.
Denis Ovsienko [Thu, 15 Apr 2021 22:22:03 +0000 (23:22 +0100)] 
Cirrus CI: Bump FreeBSD 13.0 up to the release.

(cherry picked from commit cfa6c249d2224e4cc9277241b11c42931caea431)

9 months agoCI: Remove the unused .travis.yml. [skip ci]
Denis Ovsienko [Fri, 9 Apr 2021 22:08:43 +0000 (23:08 +0100)] 
CI: Remove the unused .travis.yml. [skip ci]

The service has been disabled for a while, s390x and AArch64 CI runs
elsewhere.

(cherry picked from commit 7714a5310b08f28a5373f20132944bed0a34e9a2)

9 months agoL2TP: Add a bounds check
Francois-Xavier Le Bail [Sun, 14 Feb 2021 10:35:40 +0000 (11:35 +0100)] 
L2TP: Add a bounds check

Check if the offset padding octets are in the packet buffer.

(cherry picked and updated from commit
 5d000b07738ee13d347d721d2492f739b212fdf5)

9 months agoIP: Add a bounds check before calling ip_demux_print()
Francois-Xavier Le Bail [Fri, 12 Feb 2021 13:20:52 +0000 (14:20 +0100)] 
IP: Add a bounds check before calling ip_demux_print()

At least the header data is required.

Moreover:
Fix indentation.

(cherry picked from commit 1fb5643f91a91fe00428a6a0a0c256ba0fd2ad59)

9 months agoForCES: Refine SPARSEDATA-TLV length check.
Denis Ovsienko [Mon, 29 Mar 2021 14:49:58 +0000 (15:49 +0100)] 
ForCES: Refine SPARSEDATA-TLV length check.

When ilv_valid() returns a non-zero in sdatailv_print(), the amount of
bytes declared remaining may be insufficient to contain a complete
header, let alone any data. Thus do not try to hex dump the data,
instead print an error message and be done with it.

This fixes an inconsistency discovered by Francois-Xavier.

(cherry picked and updated from commit
 4fe72511c308b9b6a2cc094f88b40b2d0b8d8bab)

9 months agoCMake: add stuff from CMAKE_PREFIX_PATH to PKG_CONFIG_PATH.
Guy Harris [Fri, 8 Jan 2021 09:35:31 +0000 (01:35 -0800)] 
CMake: add stuff from CMAKE_PREFIX_PATH to PKG_CONFIG_PATH.

Pull in some code from CMake 3.12.4's FindPkgConfig.cmake to arrange
that, when running pkg-config, directories from CMAKE_PREFIX_PATH are in
the PKG_CONFIG_PATH environment variable.

We do this because we want to make sure that, if CMAKE_PREFIX_PATH is
set, and it points to a directory that contains a libpcap that has a .pc
file installed, we get that .pc file, but we don't yet want to require a
minimum of CMake 3.1 or later (CMake 3.1 and later do that
automatically) because there might be some long-term support OS version
that comes with an older version of CMake.

(cherry picked from commit 8ceef287ad9e3157c9ab390a102433e9203c2d90)