Commit Graph

145 Commits

Author SHA1 Message Date
Martin Tschoepe d3ec582c26 PROFINET: Ensure multiple submodules are parsed
GSML parsing has a bug related to multiple submodules,
such that, the first submodule found in the GSDML needs
to be the PROFIsafe element, otherwise the description
is not parsed.
2021-06-30 13:45:18 +00:00
João Valverde 8cf9791679 Replace some lingering references to g_log() 2021-06-19 02:34:36 +00:00
João Valverde 0e50979b3f Replace g_assert() with ws_assert() 2021-06-19 01:23:31 +00:00
João Valverde 39df3ae3c0 Replace g_log() calls with ws_log() 2021-06-16 12:50:27 +00:00
basakkalfa 7132fcaeb0 PROFINET: DCP SET Block with 0 Block Length
If there is DCP SET block with 0 block length, it is dissected
as erroneous block since DCP SET block can not have 0 block
length. Moreover, DCPBlockLength is not decoded if DCP option
and suboption is 0. However, each DCP block must have
Option/Suboption/DCPBlockLength. This is also fixed.
2021-06-09 05:23:16 +00:00
João Valverde 9ba97d12d6 Add ws_debug() and use it
Replace most instances of ws_debug_printf() except in
epan/dissectors and dissector plugins.

Some replacements use printf(), some use ws_debug(), and
some were removed because they were dead or judged to be
temporary.
2021-05-24 01:13:19 +00:00
Martin Tschoepe d9a93acc93 PROFInet: Correct handling for multiple APIs
When dissecting messages with multiple API types
within the same message, the parsing of the connect
request fails to take all elements into account.
This results in only partial parsing of the elements.

This fix ensures that all parts of the message are taken
into account and dissected correctly.
2021-05-23 20:47:50 +00:00
Guy Harris 57a1514ac7 Cast away the return value of g_strlcpy() and g_strlcat().
Most of the time, the return value tells us nothing useful, as we've
already decided that we're perfectly willing to live with string
truncation.  Hopefully this keeps Coverity from whining that those
routines could return an error code (NARRATOR: They don't) and thus that
we're ignoring the possibility of failure (as indicated, we've already
decided that we can live with string truncation, so truncation is *NOT*
a failure).
2021-04-30 03:19:19 -07:00
Gerald Combs a27391ab16 Plugins: Add missing prototypes.
Fixes -Wmissing-prototypes found by Clang.
2021-04-16 20:32:23 +00:00
Martin Mathieson d06287ec2e Some more spelling fixes.
Changed script to allow recursive search for multi-words.
2021-04-10 22:50:52 +00:00
Basak Kalfa e04ea5c108 PROFINET: Rsi dissection errors are fixed.
According to specification, size of PROFINETIOServiceResPDU
is calculated and checked under dissect_RSI_RSP_block
function. Moreover, dissect_rsi_blocks function is added and
type of PDU and operation number (Opnum) are checked before
dissection starts.
2021-04-10 08:09:18 +00:00
João Valverde d7401147b4 CMake: Remove non existent '/codecs' include path
The '/codecs' dir was removed in g63af1da7e7.

Avoid using include_directories(), prefer target_include_directories().
Remove some unnecessary CMAKE_CURRENT_*_DIR includes and some other
small cleanups while at it.
2021-03-29 00:00:57 +00:00
João Valverde 0fd2033ba2 plugin_ifdemo: Add missing QtMultimedia dependency
On my system I had to add a QtMultimedia dependency to get this plugin
to build.
2021-03-29 00:00:57 +00:00
João Valverde b807020537 'stats_tree' is not a dissector plugin (CheckAPI.pl) 2021-03-02 18:38:30 +00:00
João Valverde 8f7303df82 Fix checkapi stats_tree files
Should not include "plugin.c".
2021-03-01 21:19:40 +00:00
João Valverde 7f105d3981 CMake: Use CheckAPI's abort/termoutput with dissectors only
I believe this was the original intention, to use these API restricitons
with dissectors only (not that I necessarily agree with that policy either),
and through copy-paste and lack of clear guidelines it spread to other
parts of the build.

Rename the checkAPI groups to make it very clear that this is dissector-only.

This doesn't mean, of course, that good programming practices shouldn't be
followed everywhere. In particular assertions need to be used properly.
Don't use them to catch runtime errors or validate input data.

This commit will be followed by another removing the various ugly hacks
people have been using to get around the checkAPI hammer.
2021-03-01 20:59:39 +00:00
Vahap Emin Agaogullari e247ffa906 PROFINET: Multiple write in record dissection
COContainerContent dissects PDInterfaceMrpDataAdjust and
PDInterfaceMrpDataAdjust dissects remaining COContainerContent
because of offset problem. Offset problem is fixed.
2021-02-28 14:45:55 +00:00
Guy Harris c0711693ab Enable -Wredundant-decls.
Add it to the default list of checks, and fix some errors it causes.
(Sadly, it doesn't work in CLang.)
2021-02-14 14:43:42 -08:00
Guy Harris 2c719d4517 Generate plugin.c for tap plugins.
Instead of having the source file containing the top-level registration
routine for the pinfo_stats_tree plugin checked into our repository,
generate it with tools/make-plugin-reg.py, as we do with other plugins.

While we're at it, fix a comment - "DLL" is a Windows term; the
equivalent term in UN*Xes would be "shared object" ("so" or ".so") or
"dynamic library" ("dylib" or ".dylib").
2021-01-30 19:06:22 -08:00
Jaap Keuter 8bfff60293 Avoid CMP0071 warning when configuring with the pluginifdemo 2021-01-15 09:04:37 +00:00
Gizem Yurdagül cb65f9c150 PN: CIMVDIValue is not part of DNCP Suboption 2020-12-31 09:01:23 +00:00
Basak Kalfa 9783caebdf PROFINET: According to PN spec, RSI dissections are added.
Current Profinet Spec includes additional RSI features.
As a result, new file is added for PN-RSI protocol.
DCP substitutions related to RSI are added under PN-DCP.
PDRsiInstances record is added under PN-IO.
2020-12-29 08:43:11 +00:00
Moshe Kaplan fe6b774358 mate: replace g_malloc with g_new
Replace `g_malloc` with `g_new` to improve
source code readability.
2020-12-27 08:45:54 +00:00
Moshe Kaplan 1c7edf49f8 mate_setup: allocate correct amount of memory
When creating a _mate_cfg_gog, instead of
allocating space for a `_mate_cfg_gop`,
allocate space for a _mate_cfg_gog. Also, use
`g_new` instead of `gmalloc`.
2020-12-22 22:53:26 +00:00
Moshe Kaplan e16166a74c Detect and replace bad allocation patterns
Adds a pre-commit hook for detecting and replacing
occurrences of `g_malloc()` and `wmem_alloc()` with
`g_new()` and `wmem_new()`, to improve the
readability of Wireshark's code, and
occurrences of
`g_malloc(sizeof(struct myobj) * foo)`
with
`g_new(struct myobj, foo)`
to prevent integer overflows

Also fixes all existing occurrences across
the codebase.
2020-12-22 14:56:38 +00:00
John Thacker 15d315c2ae GLib: Bump requirement 2.32 -> 2.36 2020-11-25 06:25:38 +00:00
Martin Mathieson 07df04e4c7 Unistim: Set the length and type of IP address fields properly. 2020-11-01 19:43:24 +00:00
Jaap Keuter 5b2901d090 MATE: Improve MATE debug facility
1) Allow AVP_DEBUGGING settings to be made from Preferences, iff compiled so.
2) Flush MATE/AVP debug output once sequential packet parse has completed.
2020-10-24 18:42:50 +00:00
Jaap Keuter 87a42de393 MATE: allow _AVP_DEBUGGING flag to be set 2020-10-22 16:07:55 +00:00
Martin Mathieson 16dc0c71d3 Last batch of filter field string fixes.
There may still be some cases seen by
./toos/check_typed_item_calls.py --consecutive
that ought to be fixed, but wasn't sure so left.
2020-10-04 00:07:59 +01:00
Martin Mathieson 8b4e0148a2 Fix some more wrong filter names.
These are duplicates detected seen by running
check_typed_item_calls.py  --consecutive.

There are still quite a few more to go.
2020-09-28 18:20:09 +01:00
Basak Kalfa 91418775aa PROFINET: IOCS and IOData object dissection with Multi AR
when a new AR is established between devices which already
has another AR, same station_info was used and it caused wrong
dissection problem of IOCS and IOData objects of related AR.
In order to fix problem, new struct is added in order to match
station_info and corresponding ARs. New struct is used for
keeping ARUUID, related inputCR and outputCR frame IDs and
setup/release frame numbers of ARs. ARUUID's are used for
adding station_info data to their corresponding conversations.
If matching ARUUID and Frame IDs are found in RTC frame
dissection, then corresponding IOCS and IOData objects are
dissected.
2020-09-21 12:54:12 +00:00
Gizem Yurdagül ecbc0a5611 PROFINET: CBAVersion control is removed.
According to specification, CBA is not supported on Profinet anymore.
2020-09-10 12:13:00 +00:00
Gerald Combs 7ab6440416 Tools: Clean up checkAPI and add ui/qt.
Remove the --check-addtext and --build flags. They were used for
checkAddTextCalls, which was removed in e2735ecfdd.

Add the sources in ui/qt except for qcustomplot.{cpp,h}. Fix issues in
main.cpp, rtp_audio_stream.cpp, and wireshark_zip_helper.cpp.

Rename "index"es in packet-usb-hid.c.
2020-09-05 07:41:29 +00:00
Martin Mathieson 4f3f9ca54b Fix some spelling mistakes found among plugins. 2020-09-02 10:13:37 +01:00
Tomas Kukosa 82a4968bc3 plugin_if: add plugin_if_get_frame_data() and plugin_if_get_capture_file()
Change-Id: I7505d4185f18d13d6836c9c9bb8f400d12f2a524
Reviewed-on: https://code.wireshark.org/review/38217
Petri-Dish: Tomáš Kukosa <keksa@email.cz>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
2020-08-22 05:32:29 +00:00
Basak Kalfa 4e595577f3 PROFINET: DHCP suboption undefined bytes
There are undefined bytes which must be included in DHCP
suboption block according to DCP Block Length. In other
words, there are still bytes after dissection of defined
parameters finish but DCP block length does not finish.
In order to solve the problem, these bytes are included in
DHCP suboption block and marked Undefined. The byte number
can be 1, so bytes word in pn_user_data is changed to byte.

Change-Id: I2be23b41a9827f9c2159b97a05658ddf557865cf
Reviewed-on: https://code.wireshark.org/review/38203
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Jaap Keuter <jaap.keuter@xs4all.nl>
2020-08-20 10:46:31 +00:00
Moshe Kaplan 3b47a55b0d Replace instances of wmem_alloc with wmem_new
This commit replaces instances of
  (myobj *)wmem_alloc(wmem_X_scope(), sizeof(myobj))
and replaces them with:
  wmem_new(wmem_X_scope(), myobj)
to improve the readability of Wireshark's code.

Replacements were made with the following Python script:

import os
import re
import sys

pattern = r'\(([^\s\n]+) ?\*\) ?wmem_alloc(0?)\((wmem_[a-z]+_scope\(\)), sizeof\(\1\)\)'
replacewith = r'wmem_new\2(\3, \1)'

startdir = sys.argv[1]

for root, dirs, files in os.walk(startdir):
    for fname in files:
        fpath = os.path.join(root, fname)
        if not fpath.endswith('.c'):
            continue
        with open(fpath, 'r') as fh:
            fdata = fh.read()
        output = re.sub(pattern, replacewith, fdata)
        if fdata != output:
            print(fpath)
            with open(fpath, 'w') as fh:
                fh.write(output)

Change-Id: I223cb2fcce336bc99ca21c4a74e4cf758fd00572
Reviewed-on: https://code.wireshark.org/review/38088
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-08-08 09:54:29 +00:00
Tomas Kukosa e80d08974a pluginifdemo compilable on Windows
Change-Id: I81c40746d3e523da690205186eb3e3c2e1f26292
Reviewed-on: https://code.wireshark.org/review/37935
Petri-Dish: Tomáš Kukosa <keksa@email.cz>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-07-24 06:00:48 +00:00
vahapemin 48237f77aa Profinet: Wrong Block Length Dissection Fix
There were some cases which has zero remaining data
and it was causing an error.
Remaining Data length check added.

Change-Id: Ib0132d892e871c0f7980ff297d18c276aee26ba6
Reviewed-on: https://code.wireshark.org/review/37815
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-07-16 08:17:55 +00:00
vahapemin 734287d6d4 Profinet: ControlBlockProperties Decoded Properly
According to specification, problematic Block Decode
is fixed.

Change-Id: I0d1a13a26771231eb6f05b18325ee2bb94e975bc
Reviewed-on: https://code.wireshark.org/review/37813
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-07-10 06:26:05 +00:00
Jaap Keuter 7c855fba83 UNISTIM: Remove useless bit field true_false_string
This true_false_string does not provide anything in relation to the whole
bitfield. The field itself is questionable as a boolean anyway.
This is reported by the conflict checker.

Change-Id: I4a67db6755038b5a07ce4402181a0ea2a3a2b392
Reviewed-on: https://code.wireshark.org/review/37710
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-07-05 20:12:47 +00:00
Guy Harris e1d9a226a2 Fix the type of arrays of pointers to hf_ values for bitfield routines.
The static arrays are supposed to be arrays of const pointers to int,
not arrays of non-const pointers to const int.

Fixing that means some bugs (scribbling on what's *supposed* to be a
const array) will be caught (see packet-ieee80211-radiotap.c for
examples, the first of which inspired this change and the second of
which was discovered while testing compiles with this change), and
removes the need for some annoying casts.

Also make some of those arrays static while we're at it.

Update documentation and dissector-generator tools.

Change-Id: I789da5fc60aadc15797cefecfd9a9fbe9a130ccc
Reviewed-on: https://code.wireshark.org/review/37517
Petri-Dish: Guy Harris <gharris@sonic.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-06-19 11:32:26 +00:00
David Perry d34a806e86 UNISTIM: Refactor display address/control/tag handling
The 8 combinations of the display address, control, and tag were being
handled as 8 separate cases in `dissect_display_switch()`. This resulted
in duplicated, inconsistent code. Some paths resulted in bug #15219
while others did not have this problem.

I believe I have been able to combine them all into a single case branch
which handles each aspect correctly. I am not a UNISTIM expert and
welcome more knowledgeable reviewers.

Bug: 15219
Change-Id: Ie3eee8e19c10daab27c1df599ce0d03b52f69205
Reviewed-on: https://code.wireshark.org/review/37190
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-05-24 13:05:31 +00:00
Moshe Kaplan fd7895d37c Replace instances of wmem_alloc with wmem_new
This commit replaces instances of
  (myobj *)wmem_alloc(wmem_file_scope(), sizeof(myobj))
and replaces them with:
  wmem_new(wmem_file_scope(), myobj)
to improve the readability of Wireshark's code.

The replacement locations were identified with grep
and replaced with the Python script below.

grep command:
  egrep "wmem_alloc0?\(wmem_file_scope\(\), sizeof\([a-z_]+\)\)" . -R -l

python script:

import re
import sys
import fileinput

pattern = r'\(([^\s]+) ?\*\) ?wmem_alloc(0?)\((wmem_[a-z]+_scope\(\)), sizeof\(\1\)\)'
replacewith = r'wmem_new\2(\3, \1)'

fname = sys.argv[1]

for line in fileinput.input(fname, inplace=1, mode='rb'):
    output = re.sub(pattern, replacewith, line)
    sys.stdout.write(output)

Change-Id: Ieac246c104bf01e32cbc6e11e53e81c7f639d870
Reviewed-on: https://code.wireshark.org/review/37158
Petri-Dish: Pascal Quantin <pascal@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Pascal Quantin <pascal@wireshark.org>
2020-05-07 14:47:54 +00:00
Dario Lombardo 772813fcc7 pluginifdemo: fix compilation when it's enabled.
Enable the plugin with ENABLE_PLUGIN_IFDEMO=1.

Change-Id: I8ebc076d3b4ea66443d58e57dce0d235a214a2bb
Reviewed-on: https://code.wireshark.org/review/36606
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2020-04-02 08:50:06 +00:00
Gerald Combs 6dad599a8a WiMax DLMAP: Fix a large loop.
Make sure we advance our offset.

Bug: 16383
Ping-Bug: 16368
Change-Id: I4949cb0988601dbe545d0bc22de4d654b4e61204
Reviewed-on: https://code.wireshark.org/review/36085
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-02-13 12:17:09 +00:00
Gerald Combs 7ce2ca316c WiMax DLMAP: Add a length check.
Make sure we have enough data for a CRC.

Bug: 16368
Change-Id: I03a2532061a5cf5e28cb65c83dd4ab90654d1679
Reviewed-on: https://code.wireshark.org/review/36048
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2020-02-07 19:59:04 +00:00
Basak Kalfa 8f4cd818ee Profinet: Two new bugs are detected and fixed.
Bug at dissection of ARData is fixed. Moreover,
there is also bug in DCP's DHCP suboption and it
is also fixed.

Change-Id: I185e66f957f330dae587fc63b76cd50f567f5f9b
Reviewed-on: https://code.wireshark.org/review/35974
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-01-28 12:28:14 +00:00
Dario Lombardo 084a887a30 Fix compilation with gcc-9.
gcc-9 spotted some NULL pointer usages.

Bug: 16319
Change-Id: I3e4ac57705f1852c43299f5e924fc642a2c56a3a
Reviewed-on: https://code.wireshark.org/review/35733
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-01-21 04:44:31 +00:00