Commit Graph

7569 Commits

Author SHA1 Message Date
Francois-Xavier Le Bail
57f1c409a4 CI: Add TinyCC (aka TCC) support
Identification examples: tcc-0.9.27, tcc-0.9.28rc

There are currently warnings such as:
print-802_11.c:3317: warning: assignment discards qualifiers from pointer
  target type
print-esp.c:373: warning: function might return no value: 'ldp_pdu_print'
So use: TCPDUMP_TAINTED=yes

Works on linux-amd64.
Does not work on linux-armv7l with BUILD_LIBPCAP=yes / CMAKE=yes
(Segmentation fault, libpcap dynamically linked). Works with 0.9.28rc.

TinyCC can be found at https://bellard.org/tcc/,
https://repo.or.cz/r/tinycc.git or as package on some distros.
2024-05-20 11:17:09 +00:00
Guy Harris
83d7ac7aac esp: report a warning, not an error, for an invalid hex digit in a secret.
We already report a warning if the secret is too long; do so if there's
an invalid hex digit in the secret.

See

https://github.com/the-tcpdump-group/tcpdump/pull/1185#issuecomment-2119211162

While we're at it, put the length of the string, in hex-digit pairs,
into a size_t rather than an unsigned int, just in case (it's unlikely
that it will overflow a 32-bit unsigned integer, but...).
2024-05-19 23:03:32 -07:00
Guy Harris
d5b1a160a3 Get rid of support for libpcap prior to 1.0.
This lets us remove a bunch of configure-time and compile-time tests.

Update documentation to reflect this.

WinPcap 4.1.3 is based on libpcap 1.0, but doesn't export all of the new
APIs, so it won't work with code that uses any of the other APIs, which
tcpdump does, so don't test with WinPcap.
2024-05-19 12:43:23 -07:00
Guy Harris
074d10aa1a esp: mark unreached code as such.
Some compilers might not understand the declaration of the ndo_error
member of an netdissect_options as pointing to a function that never
returns; add a /* NOTREACHED */ comment in case they recognize that as a
hint.
2024-05-19 12:25:59 -07:00
Francois-Xavier Le Bail
47edb26bde NFS: Add two length checks
This change avoids adding a large number to the packet pointer and
overflow it.

It also avoids the differences between 32-bit and 64-bit printouts.

Example:
32-bit:
NFS request xid 1168185174 80 readdirplus fh / 1441792 bytes @ 1585267068834414592 [|nfs]
---
64-bit:
NFS request xid 1168185174 80 readdirplus [|nfs]

Add a test file.
Update a test output accordingly.
2024-05-08 19:12:19 +00:00
Francois-Xavier Le Bail
067f7dd17d frag6: Fix invalid 32-bit versus 64-bit printouts
Print "[length < 0] (invalid)" when fragment length is negative.

In this case, e.g. when IPv6 payload length is zero, the 32-bit and
64-bit printouts were different.

Example:
32-bit:
frag (0x80000074:1280|4294967288)
---
64-bit:
frag (0x80000074:1280|18446744073709551608)

Add a test file.
2024-05-06 19:10:03 +00:00
Francois-Xavier Le Bail
e5b1cab048 Autoconf: Update an AC_DEFINE()
Same result in config.h as with CMake.

Before:
#define NETINET_ETHER_H_DECLARES_ETHER_NTOHOST /**/

After:
#define NETINET_ETHER_H_DECLARES_ETHER_NTOHOST 1

[skip ci]
2024-05-03 09:15:51 +02:00
Francois-Xavier Le Bail
6d1136ac57 TESTrun: Print HAVE_FPTYPE1/HAVE_FPTYPE2 based on the --fp-type option 2024-04-29 11:59:57 +02:00
Francois-Xavier Le Bail
37745f6daa frag6: Refactor duplicate code
Update a test output accordingly.
2024-04-27 10:19:37 +02:00
Francois-Xavier Le Bail
429c68e33b IPv6: Update a comment
"advance" is used since commit 66df248b49.

[skip ci]
2024-04-27 08:42:55 +02:00
Denis Ovsienko
4822cd1f88 README.md: Add QNX to the formerly supported OS list. [skip ci]
There are various mentions of QNX implementing BPF and running tcpdump,
but finding an actual running OS and verifying it seems complicated.
2024-04-24 22:56:35 +01:00
Francois-Xavier Le Bail
bb704ed32d Rename the suffix of a pcap test file to .pcap 2024-04-17 10:57:19 +02:00
Guy Harris
baa6d9b864 SLL2: indicate why we only do interface lookup on Linux. [skip ci] 2024-04-15 13:57:29 -07:00
Francois-Xavier Le Bail
4ffb715478 CHANGES: Update an entry to avoid any misunderstanding
[skip ci]
2024-04-13 11:41:57 +02:00
Francois-Xavier Le Bail
1ed3921b6b CHANGES: Sync with the 4.99 branch
[skip ci]
2024-04-10 10:30:07 +02:00
Denis Ovsienko
cc0dc6a97c Fix deprecation macros for old Sun C. [skip ci]
As Francois-Xavier points it out, my recent commit 5265743 in certain
contexts adds rather than removes compiler warnings:

cc: Sun C 5.12 SunOS_i386 Patch 148918-11 2017/12/13
"tcpdump.c", line 3267: warning: bad message tag: E_DEPRECATED_ATT
"tcpdump.c", line 3307: warning: bad message tag: E_DEPRECATED_ATT

Get Sun C versions right to fix that.
2024-04-09 15:05:37 +01:00
Francois-Xavier Le Bail
7652b93066 CHANGES: Add two changes backported to the 4.99 branch
[skip ci]
2024-04-09 14:50:01 +02:00
Francois-Xavier Le Bail
420f9f215b mkdep: Exit with a non-zero status if a command fails
This could help detect errors such as in the previous commit.
2024-04-09 12:37:23 +00:00
Francois-Xavier Le Bail
db1e124f49 Makefile.in: Fix the depend target
Fix an error on Solaris 10 like:
./mkdep: /opt/solarisstudio12.3/bin/cc -D_STDC_C99=: not found

When configure get some compiler option like:
checking for /opt/solarisstudio12.3/bin/cc option to accept ISO C99...
-D_STDC_C99=
Makefile will contain:
CC = /opt/solarisstudio12.3/bin/cc -D_STDC_C99=

And if we use '-c "$(CC)"' mkdep will set and try to run:
CC="/opt/solarisstudio12.3/bin/cc -D_STDC_C99=", which is incorrect.

Remove the quotes to allow mkdep to set CC with the compiler name and
set flags with the option.
2024-04-09 12:37:23 +00:00
Guy Harris
7d48702a91 Extract common file rotation code into routines. 2024-04-07 22:24:24 -07:00
Francois-Xavier Le Bail
55b522a3ed CHANGES: Add a change in the main section
[skip ci]
2024-04-07 20:15:22 +02:00
Francois-Xavier Le Bail
1f583a44e1 Makefile.in: Update the .c.o build rule
Don't use the hacks for the rather old SunOS 4.

It's helps to do VPATH builds, e.g. 32-bit, 64-bit in two directories.
(https://www.gnu.org/software/automake/manual/html_node/VPATH-Builds.html)
2024-04-07 17:51:29 +00:00
Denis Ovsienko
a0ffbfba6c CMake: Get the comment about EXTRA_CFLAGS right. [skip ci]
The "testprogs" sentence applies to libpcap only.
2024-04-05 15:17:08 +01:00
Denis Ovsienko
af7e049e77 doc: Add recent OmniOS and OpenIndiana details. 2024-04-05 14:55:34 +01:00
Denis Ovsienko
4e99e07496 CHANGES: Move the cc_werr_cflags() entry to 4.99.5. 2024-04-05 12:01:59 +01:00
Francois-Xavier Le Bail
6eccce9a7c CHANGES: Move a backported change to the 4.99 branch
Use Autoconf with 'A', as this is the official name of the package.

[skip ci]
2024-04-03 13:30:33 +02:00
Francois-Xavier Le Bail
42116158c3 Update the error message when checking for pcap_loop()
Add a first error case when trying to build a 32-bit tcpdump with a
64-bit libpcap or vice versa.

[skip ci]
2024-04-03 04:43:09 +00:00
Denis Ovsienko
0e04b9da80 SLL2: Translate interface indices to names on Linux only.
print-sll.c uses HAVE_NET_IF_H, which does not always work right: the
header is in POSIX.1-2001, but the result of if_indextoname() is
irrelevant if the current OS is not Linux, in which case the packet was
captured on a different host because libpcap produces DLT_LINUX_SLL2 on
Linux only.  The result can be irrelevant on Linux too, but this does
not have an easy solution.

To reduce the problem space, switch print-sll.c to check for __linux__
instead.  In tcpdump.c print the warning about interface names only if
sll2_if_print() would print interface names.  Since HAVE_NET_IF_H has no
purpose now, remove the checks for <net/if.h>.
2024-04-02 11:36:13 +01:00
Denis Ovsienko
b779eda489 Include diag-control.h only where necessary.
Neither addrtoname.c nor extract.h nor netdissect.h nor print-sll.c
require the header anymore, so do not include it there.  Add a missing
conditional include to netdissect.c.
2024-04-02 11:36:13 +01:00
Rose
9b97f85e62 Prefer calloc over malloc
This makes the code cleaner anyway and avoids branching.
2024-04-02 11:19:15 +01:00
Francois-Xavier Le Bail
5a25aeddad Cirrus CI: Add the binutils-dev package, Linux task
It is needed to build with --enable-instrument-functions
(make releasecheck).
2024-04-02 12:01:43 +02:00
Denis Ovsienko
778e4bfd4e Cirrus CI: Reduce the footprint a little bit. [skip appveyor]
Same as in libpcap.
2024-04-01 17:48:42 +01:00
Denis Ovsienko
f80e2dcc0d Cirrus CI: Do not test on FreeBSD 14.0. [skip ci]
Buildbot does it now.
2024-03-31 10:32:59 +01:00
Francois-Xavier Le Bail
dab871e8be Fix incompatible pointer types with time functions calls on Windows
On Windows in a struct timestamp, tv_sec is a long not a 64-bit time_t.

The problem shows:
listening on \Device\NPF_Loopback, link-type NULL (BSD loopback),
snapshot length 262144 bytes
    1  [localtime() or gmtime() couldn't convert the date and time].052255
       IP 10.0.0.10 > 224.0.0.251: igmp v2 report 224.0.0.251
    2  [localtime() or gmtime() couldn't convert the date and time].792000
       IP 10.0.0.10.138 > 10.0.0.255.138: NBT UDP PACKET(138)

The warnings with clang-cl were:
util-print.c(253,18): warning: incompatible pointer types passing
  'const long *' to parameter of type 'const time_t *'
      (aka 'const long long *') [-Wincompatible-pointer-types]
  253 |                 tm = localtime(&tv->tv_sec);
      |                                ^~~~~~~~~~~

util-print.c(255,15): warning: incompatible pointer types passing
  'const long *' to parameter of type 'const time_t *'
      (aka 'const long long *') [-Wincompatible-pointer-types]
  255 |                 tm = gmtime(&tv->tv_sec);
      |                             ^~~~~~~~~~~
2024-03-29 13:24:27 -07:00
Denis Ovsienko
ef765a04a6 Autoconf: Do not check for C99 uintptr_t. [skip appveyor]
At the time of commit 09b639a in 2015 C99 was not a requirement yet, so
the use of AC_TYPE_UINTPTR_T was necessary.  However, CMake since its
introduction in 2018 has not been checking for uintptr_t, which proves
that by now all supported platforms have the type and the Autoconf check
is obsolete.
2024-03-29 11:40:32 +00:00
Francois-Xavier Le Bail
f81ffd1754 Include <fcntl.h> unconditionally
It is used for open() which is in POSIX.1-2001, POSIX.1-2008.

libpcap has included <fcntl.h> unconditionally since at least 1999.
2024-03-29 06:11:55 +00:00
Guy Harris
e57fe28eb2 ZEP: use the exissting NTP time formatting code.
The strftime() format for that case is slightly different, so add a new
p_ntp_time_fmt() routine that takes a strftime() format, and use that in
ZEP.

That way, we can benefit from any handling of times not fitting in a
time_t being done by the NTP time printing code.
2024-03-28 22:49:42 -07:00
Guy Harris
433405d2a0 SMB: clean up date handling.
Pull the routine that carves a DOS date/time up and puts it into a
struct tm into the routine that converts the struct tm into a time_t.

Note a place where a DOS date/time might not fit in a 32-bit integral
time_t (DOS dates and times can go past the Y2.038K date/time).

Do the NT FILETIME to time_t conversion as an all-integer operation.
Catch cases where the result doesn't fit into a time_t.  (And rename the
routine to speak of it as a FILETIME; that's what it's called.)
2024-03-28 22:45:47 -07:00
Guy Harris
cf3566e677 AppVeyor: try building with Visual Studio 2022. 2024-03-28 21:31:50 -07:00
Guy Harris
b820ca8237 doc: rename README.Win32.md to README.windows.md.
That matches the name of the equivalent libpcap document, and doesn't
tie it to 32 bits.  (16-bit Windows is long since dead.)
2024-03-28 17:20:55 -07:00
Guy Harris
f23d7f6355 CHANGES: mention a change backported to 1.10. [skip ci] 2024-03-28 17:06:06 -07:00
Guy Harris
2e689a60c3 doc: fix RADME.Win32.md issues. [skip ci]
This fixes #1158.
2024-03-28 17:02:13 -07:00
Francois-Xavier Le Bail
80dce061dd Remove an unneeded include
Remove <fcntl.h> conditional include from util-print.c.

Historically read_infile() was in util.c and used open(), so needed it.
When part of util.c became util-print.c without read_infile(),
the include was left without need.
2024-03-28 18:48:08 +00:00
Francois-Xavier Le Bail
94a3708f00 Include <config.h> unconditionally
Builds using Autotools or CMake generate config.h, thus remove the
'#ifdef HAVE_CONFIG_H'/'#endif'.

Remove also the 'add_definitions(-DHAVE_CONFIG_H)' in CMakeLists.txt.
2024-03-28 05:34:34 +00:00
Guy Harris
67a4492f9d cmake: change a comment to match config.h.in. [skip ci] 2024-03-27 18:40:42 -07:00
Guy Harris
0792dd93f4 AppleTalk: use nd_byte for AppleTalk addresses.
Make them arrays of nd_byte, rather than uint8_t; they're both unsigned
one-byte values, but nd_byte makes it clearer that they're not arrays of
4 one-byte unsigned integer values.
2024-03-27 18:35:46 -07:00
Denis Ovsienko
e1bcb7941d Simplify the checks for snprintf().
Do not check that the function is just available: first, it is in C99,
so the check almost certainly is a waste of time; second, the source
requires the function unconditionally; third, the subsequent "snprintf()
is suitable" check implies the "snprintf() is available" part anyway.
2024-03-27 23:46:15 +00:00
Richard Scheffenegger
55dc3206aa TCP: Add support for the AE (AccECN) flag.
Print the new flag using lowercase "e" to avoid confusion with the
existing uppercase flags and "." for ACK.  Add/update tests.  Document
it in the man page using "AE" as the shorthand.
2024-03-27 11:19:34 +00:00
Denis Ovsienko
5eea8486d0 Cirrus CI: Switch FreeBSD from 13.2 to 13.3. [skip appveyor] 2024-03-27 09:44:16 +00:00
Denis Ovsienko
cf728f6dce Autoconf: Lose AC_C_INLINE: inline is in C99. 2024-03-27 09:44:16 +00:00