Commit Graph

37 Commits

Author SHA1 Message Date
Peter Wu 7e88bb5e53 fuzzshark: integrate oss-fuzz targets in CMake
The current fuzzshark target built by CMake is not usable for fuzzing.
Address this by adding a new ENABLE_FUZZER option that enables mandatory
instrumentation and libFuzzer linking options for the fuzzshark binary.

Create more CMake targets for specific fuzzing targets such as
fuzzshark_ip and fuzzshark_ip_proto-udp. These targets are not built by
default, either build individual targets or use the all-fuzzers target.

Now these binaries are not specific to oss-fuzz, so move them to a new
directory (perhaps the corpora can be added here in the future).
oss-fuzz build.sh is simplified and reuses the CMake targets.

When OSS_FUZZ is set, it will force static linking with external
libraries and limit parallel linker jobs (maybe not necessary for
Google's oss-fuzz builders, but my 8G/6c VM ran out of memory).

Change-Id: If3ba8f60ea1f5c3bd2131223050a81f9acbce05d
Reviewed-on: https://code.wireshark.org/review/30228
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-10-20 07:00:43 +00:00
João Valverde ff1e16055f epan: Add argument to epan_init() to disable plugins
Change-Id: I8dc76e6bf8c4d5a3081cbdc1d47b88e857415d29
Reviewed-on: https://code.wireshark.org/review/29498
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot
Reviewed-by: João Valverde <j@v6e.pt>
2018-09-09 02:27:34 +00:00
Gerald Combs ef01359849 Add support for protocol aliases. Switch BOOTP to DHCP.
Add support for aliasing one protocol name to another and for filtering
using aliased fields. Mark aliased fields as deprecated.

Rename the BOOTP dissector to DHCP and alias "bootp" to "dhcp". This
lets you use both "dhcp.type" and "bootp.type" as display filter fields
without having to duplicate all 500+ DHCP/BOOTP fields.

To do:
- Add checks to proto.c:check_valid_filter_name_or_fail?
- Transition SSL to TLS.
- Rename packet-bootp.c to packet-dhcp.c?

Change-Id: I29977859995e8347d80b8e83f1618db441b10279
Ping-Bug: 14922
Reviewed-on: https://code.wireshark.org/review/29327
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-08-31 05:25:17 +00:00
João Valverde 8eddb1650d epan: Remove unnecessary all protocols registration callback
We are exporting a registration function from libwireshark just
to have it passed back as a callback. Seems unnecessary.

Change-Id: I7621005c9be11691d319102326824c5e3520a6f3
Reviewed-on: https://code.wireshark.org/review/29328
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot
Reviewed-by: João Valverde <j@v6e.pt>
2018-08-29 23:22:44 +00:00
Guy Harris 15cfc41e94 Don't use dladdr() to get a pathname for the current executable().
Change-Id: I24ad11a659c2cb936f873339dc2b36ac9944280a
Reviewed-on: https://code.wireshark.org/review/27359
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-05-05 08:06:35 +00:00
Stig Bjørlykke 14720ace06 Fix comment end after SPDX identifier
Move */ to a separate line below the SPDX identifier.

Change-Id: Id1032215449cfccae0933147b45e04b65e0b727f
Reviewed-on: https://code.wireshark.org/review/27211
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-01 06:56:37 +00:00
Jakub Zawadzki 4a488919e3 oss-fuzzshark: use install directory for headers. Install missing one.
From compilation log:
  epan/ipv4.h:19:10: fatal error: 'wsutil/inet_ipv4.h' file not found
  tools/oss-fuzzshark/fuzzshark.c:27:10: fatal error: 'version_info.h' file not found

Change-Id: I3e147e014ae398ae07e64aec5a6535a8f9e357a3
Reviewed-on: https://code.wireshark.org/review/27076
Petri-Dish: Jakub Zawadzki <darkjames-ws@darkjames.pl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-04-24 03:49:15 +00:00
Dario Lombardo fe71e26af2 spdx: more licenses converted.
Change-Id: I3861061ec261e63b23621799e020e811ed78a343
Reviewed-on: https://code.wireshark.org/review/26333
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-03-07 15:56:44 +00:00
Dario Lombardo 8a5385b9c9 More licenses converted to SPDX.
Change-Id: Id4f987dcdacf06622d70263f4659a4400e30dc39
Reviewed-on: https://code.wireshark.org/review/26332
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-03-07 13:35:49 +00:00
Jakub Zawadzki bc43d687f0 fuzzshark: don't fuzz udplite.
Don't fuzz IP->udplite protocol. It's using most of UDP code,
but cause udplite calls also udp dissectors it duplicates
work of UDP fuzzer.

This should also decrease IP corpus size, cause in IP corpus
~7.6% (9 165 out of 119 780) is udplite ip.proto

Change-Id: I1d3bde6dd34f76696a34b1c728ce36f3c802e6c9
Link: https://github.com/google/oss-fuzz/issues/1087
Reviewed-on: https://code.wireshark.org/review/25950
Petri-Dish: Jakub Zawadzki <darkjames-ws@darkjames.pl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Jakub Zawadzki <darkjames-ws@darkjames.pl>
2018-02-20 23:02:38 +00:00
Your Name a660215dea fuzzshark: disable reassembly for few protocols
Reassembly (or in general being stateful) doesn't help when fuzzing,
even if wireshark will crash oss-fuzz will try to reproduce the crash
with just single sample.

Single sample will not reproduce the crash, so being stateful makes
wireshark 'buggy target'.

I hope change will also make IP corpus a little bit smaller.

Change-Id: I01ba8177a653d220c4cfe8a56a5836c96010c6fe
Reviewed-on: https://code.wireshark.org/review/25799
Reviewed-by: Jakub Zawadzki <darkjames-ws@darkjames.pl>
2018-02-15 06:03:34 +00:00
Jakub Zawadzki a958533c6a fuzzshark: disable protocol in fuzzer if it's used by other fuzzer.
Change-Id: I4dcc38b2ac9711660c8cf27cbbabd879c2eee930
Link: https://github.com/google/oss-fuzz/issues/1087
Reviewed-on: https://code.wireshark.org/review/25738
Petri-Dish: Jakub Zawadzki <darkjames-ws@darkjames.pl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-02-12 06:39:04 +00:00
Guy Harris 1f5f63f8ef Generalize wtap_pkthdr into a structure for packet and non-packet records.
Separate the stuff that any record could have from the stuff that only
particular record types have; put the latter into a union, and put all
that into a wtap_rec structure.

Add some record-type checks as necessary.

Change-Id: Id6b3486858f826fce4b096c59231f463e44bfaa2
Reviewed-on: https://code.wireshark.org/review/25696
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-02-09 00:29:51 +00:00
Dario Lombardo 8cd389e161 replace SPDX identifier GPL-2.0+ with GPL-2.0-or-later.
The first is deprecated, as per https://spdx.org/licenses/.

Change-Id: I8e21e1d32d09b8b94b93a2dc9fbdde5ffeba6bed
Reviewed-on: https://code.wireshark.org/review/25661
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-02-08 14:57:36 +00:00
Dario Lombardo d9368545f4 fuzzshark: use SPDX identifier.
Change-Id: I9c786b8bbb96a4bfa1560536c3929b844aa8afb7
Reviewed-on: https://code.wireshark.org/review/25562
Reviewed-by: Michael Mann <mmann78@netscape.net>
2018-02-02 13:38:48 +00:00
Jakub Zawadzki d1b1575f6d oss-fuzzshark: try to fix oss-fuzz assert fails.
Change-Id: Ic4ff70dfc55b2694f761cdadcac1962242fca753
Reviewed-on: https://code.wireshark.org/review/25551
Reviewed-by: Jakub Zawadzki <darkjames-ws@darkjames.pl>
2018-02-01 17:35:16 +00:00
Jakub Zawadzki dd3b82ebc8 oss-fuzzshark: test code to debug some oss-fuzz assert fails.
Change-Id: I5dbe899ca8a4f9107d62667ca107a4d3a48fe51b
Reviewed-on: https://code.wireshark.org/review/25545
Reviewed-by: Jakub Zawadzki <darkjames-ws@darkjames.pl>
2018-02-01 07:08:59 +00:00
Pascal Quantin fc9af81a13 wiretap: add a parameter to wtap_init() indicating whether plugins must be loaded
g995812c5f1 moved wiretap plugins registration from applications to
wiretap library init function.
As we do not want to load plugins for all users of libwiretap, let's
make it configurable.

Bug: 14314
Change-Id: Id8fdcc484e2d0d31d3ab0bd357d3a6678570f700
Reviewed-on: https://code.wireshark.org/review/25194
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-01-09 21:25:06 +00:00
Alexis La Goutte 917867c432 fuzzshark: fix no previous prototype for function 'LLVMFuzzerTestOneInput/LLVMFuzzerInitialize' [-Wmissing-prototypes]
Change-Id: If5f425dda3cd793a63a69680c12aba12a20ed12e
Reviewed-on: https://code.wireshark.org/review/24917
Petri-Dish: Jakub Zawadzki <darkjames-ws@darkjames.pl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-12-21 00:04:18 +00:00
João Valverde 995812c5f1 Refactor plugin registration and loading
Put different types of plugins (libwiretap, libwireshark) in different
subdirectories, give libwiretap and libwireshark init routines that
load the plugins, and have them scan the appropriate subdirectories
so that we don't even *try* to, for example, load libwireshark plugins
in programs that only use libwiretap.

Compiled plugins are stored in subfolders of the plugin folders, with
the subfolder name being the Wireshark minor version number (X.Y). There is
another hierarchical level for each Wireshark library (libwireshark, libwscodecs
and libwiretap).

The folder names are respectively plugins/X.Y/{epan,codecs,wiretap}.

Currently we only distribute "epan" (libwireshark) plugins.

Change-Id: I3438787a6f45820d64ba4ca91cbe3c8864708acb
Reviewed-on: https://code.wireshark.org/review/23983
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot
Reviewed-by: João Valverde <j@v6e.pt>
2017-12-14 08:43:57 +00:00
Guy Harris 7539469d79 Fix types.
ftell() returns a long; assign its value to a variable of that type.
size_t is unsigned, so checking that it's >= 0 always succeeds.

We can cast the variable's value to size_t once we've determined that it's
non-negative; do so, to avoid other warnings.

Change-Id: I0da6a220ce140ebf073df5f5bcd0c9526bf9c3c3
Reviewed-on: https://code.wireshark.org/review/24817
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-12-14 02:44:51 +00:00
Dario Lombardo 326591ef6d fuzzer: add check for ftell return value (CID: 1426073).
Change-Id: I9b619c79433f267d87f6680eeb78a25daa169f4d
Reviewed-on: https://code.wireshark.org/review/24778
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-12-12 14:56:54 +00:00
Jakub Zawadzki 157ea91f2e oss-fuzzshark: fix compilation.
/src/wireshark/tools/oss-fuzzshark/fuzzshark.c:268:58: error: too few arguments to function call, expected 2, have 1
        fuzz_handle = get_dissector_handle(FUZZ_DISSECTOR_TARGET);
                      ~~~~~~~~~~~~~~~~~~~~                      ^
/src/wireshark/tools/oss-fuzzshark/fuzzshark.c:133:1: note: 'get_dissector_handle' declared here

Change-Id: I6c6e25017f0045b833d9249c9648145893fe0439
Reviewed-on: https://code.wireshark.org/review/24742
Petri-Dish: Jakub Zawadzki <darkjames-ws@darkjames.pl>
Reviewed-by: Jakub Zawadzki <darkjames-ws@darkjames.pl>
2017-12-08 19:39:37 +00:00
Guy Harris 48e65c4af4 Hand the packet provider functions to epan_new().
Have separate packet_provider_data structures and packet_provider_funcs
structures; the latter holds a table of functions that libwireshark can
call for information about packets, the latter holds the data that those
functions use.

This means we no longer need to expose the structure of an epan_t
outside epan/epan.c; get rid of epan/epan-int.h.

Change-Id: I381b88993aa19e55720ce02c42ad33738e3f51f4
Reviewed-on: https://code.wireshark.org/review/24732
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-12-08 04:33:55 +00:00
Guy Harris 797d2f6a87 Move the frame_set stuff back into the capture_file structure.
libwireshark now expects an epan_t to be created with a pointer to a
"packet provider" structure; that structure is opaque within
libwireshark, and a pointer to it is passed to the callbacks that
provide interface names, interface, descriptions, user comments, and
packet time stamps, and that set user comments.  The code that calls
epan_new() is expected to provide those callbacks, and to define the
structure, which can be used by the providers.  If none of the callbacks
need that extra information, the "packet provider" structure can be
null.

Have a "file" packet provider for all the programs that provide packets
from a file.

Change-Id: I4b5709a3dd7b098ebd7d2a7d95bcdd7b5903c1a0
Reviewed-on: https://code.wireshark.org/review/24731
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-12-08 03:32:25 +00:00
Jakub Zawadzki 038aa2a616 Add fuzzshark to cmake/autotools.
Add fuzzshark target to make sure that oss-fuzzshark always build.

Change-Id: I802b679c18023daa1475a54bae722b5e90c72a59
Reviewed-on: https://code.wireshark.org/review/24716
Petri-Dish: Jakub Zawadzki <darkjames-ws@darkjames.pl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2017-12-07 23:26:52 +00:00
Jakub Zawadzki 038fe4c2d4 oss-fuzzshark: fix handler of epan->get_frame_ts to fix build.
Fix oss-fuzzshark build after [1834dca365]: Move the parts of a capture_file used by libwireshark to a new structure.

I really need to integrate oss-fuzzshark with build system...

Change-Id: I75595db392acfbdb7885975e458d8b434830cfec
Reviewed-on: https://code.wireshark.org/review/24713
Petri-Dish: Jakub Zawadzki <darkjames-ws@darkjames.pl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Jakub Zawadzki <darkjames-ws@darkjames.pl>
2017-12-06 18:41:31 +00:00
Guy Harris eb8ffb74e2 Use cfile.h to define the capture_file type.
Have cfile-int.h declare the structure, and use it in files that
directly access the structure.

Have cfile.h just incompletely declare the structure and include it
rather than explicitly declaring it in source files or other header
files.

Never directly refer to struct _capture_file except when typedeffing
capture_file.

Add #includes as necessary, now that cfile.h doesn't drag in a ton of

Change-Id: I7931c8039d75ff7c980b0f2a6e221f20e602a556
Reviewed-on: https://code.wireshark.org/review/24686
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-12-03 18:54:37 +00:00
Gerald Combs 28b6616ea0 Get rid of some void pointers.
Explictly struct _capture_file * in epan_session and its callbacks.

Change-Id: I63703015c661a08f3350a7448a7bcdaf98f119dc
Reviewed-on: https://code.wireshark.org/review/24675
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-12-01 21:09:24 +00:00
João Valverde 7540ac6938 Move the protocol registration routines back into libwireshark
Follow-up to b695b3e2f7.

Change-Id: I7e36519f2c3806c1205d05437671325080974257
Reviewed-on: https://code.wireshark.org/review/24524
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot
Reviewed-by: João Valverde <j@v6e.pt>
2017-11-21 20:21:50 +00:00
Jakub Zawadzki 2ad1507344 oss-fuzzshark: fix linking issues due to register_all_protocols() removed from -lepan
During compilation of oss-fuzzshark (https://github.com/google/oss-fuzz/issues/1003):
Step #3: /src/wireshark/tools/oss-fuzzshark/fuzzshark.c:213: undefined reference to `register_all_protocols'
Step #3: /src/wireshark/tools/oss-fuzzshark/fuzzshark.c:213: undefined reference to `register_all_protocol_handoffs'

After cleanup of make-dissector-reg.py [b695b3e2f7]
these functions are no longer part of epan library (I really wonder why...).
oss-fuzzshark need to compile and link register.c on their own.

Change-Id: I79adf5c1513a0934f140bbf501c181bf14d7619b
Reviewed-on: https://code.wireshark.org/review/24523
Petri-Dish: Jakub Zawadzki <darkjames-ws@darkjames.pl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Jakub Zawadzki <darkjames-ws@darkjames.pl>
2017-11-21 18:23:35 +00:00
Michael Mann 1741b6b23c oss-fuzzshark: force direct malloc
Set two environment variables (needs to be done before epan_init and
before the first g_slice_alloc call) to force direct memory allocation
without another layer that could hide bugs.

Change-Id: I0d72092c239e2e7f42b0b7849c01471407e785e2
Reviewed-on: https://code.wireshark.org/review/21195
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-11-04 13:14:23 +00:00
Jakub Zawadzki b4a6f4e244 oss-fuzzshark: add missing include to fix implicit declaration of color_filters_init()
/src/wireshark/tools/oss-fuzzshark/fuzzshark.c:218:7: warning: implicit declaration of function 'color_filters_init' is invalid in C99 [-Wimplicit-function-declaration]
        if (!color_filters_init(&err_msg, NULL))
             ^
1 warning generated.

Change-Id: I37dbc4521b6a3cda271e6e33a290ed35911e7dda
Reviewed-on: https://code.wireshark.org/review/24086
Petri-Dish: Jakub Zawadzki <darkjames-ws@darkjames.pl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-10-26 19:52:56 +00:00
João Valverde a269ae1b6a Rename "ws_version_info.h", also .c
It's not installed so like most other files it doesn't need or benefit
from the prefix.

Change-Id: I01517e06f12b3101fee21b68cba3bc6842bbef5c
Reviewed-on: https://code.wireshark.org/review/23751
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: João Valverde <j@v6e.pt>
2017-09-26 17:32:08 +00:00
Guy Harris 60da2c96dd Just print the string color_filters_init() provides on an error.
It gives all the necessary details; no need to mention the name of a
routine the existence of which the user is probably unaware.

Change-Id: I66d372bc6650c84fbbc6be438be695eff1048413
Reviewed-on: https://code.wireshark.org/review/22055
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-06-09 22:38:35 +00:00
Jakub Zawadzki 13fbdfc1ba fuzzshark: try to fix oss-build, remove oss-fuzzshark.c in old location.
Step #3: /src/wireshark/tools/oss-fuzzshark.c:190:2: warning: implicit declaration of function 'wtap_init' is invalid in C99 [-Wimplicit-function-declaration]
(https://oss-fuzz-build-logs.storage.googleapis.com/log-472514ce-1a41-4f14-8798-d45084212a65.txt)

Change-Id: I47715bdf55c20124a80da51d3c8812db1d8d94cf
Reviewed-on: https://code.wireshark.org/review/21317
Reviewed-by: Jakub Zawadzki <darkjames-ws@darkjames.pl>
Petri-Dish: Jakub Zawadzki <darkjames-ws@darkjames.pl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
2017-04-24 20:50:53 +00:00
Jakub Zawadzki 9785aed5b6 oss-fuzzshark: Copy to separate directory, add build script.
(oss-fuzz part https://github.com/google/oss-fuzz/pull/544)

Change-Id: I54cf7a7b1aaa49582b5fff8bd034187aa6a9bdec
Reviewed-on: https://code.wireshark.org/review/21302
Petri-Dish: Jakub Zawadzki <darkjames-ws@darkjames.pl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Jakub Zawadzki <darkjames-ws@darkjames.pl>
2017-04-24 16:50:26 +00:00