Commit Graph

17 Commits

Author SHA1 Message Date
João Valverde 0e50979b3f Replace g_assert() with ws_assert() 2021-06-19 01:23:31 +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
Guy Harris 3a0dd69d04 Get rid of some GTK+-only stuff.
Change-Id: I841a1cdb637f37673466e4d065474c0f7e2dfc56
Reviewed-on: https://code.wireshark.org/review/27512
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-05-13 19:46:45 +00:00
Dario Lombardo 55c68ee69c epan: use SPDX indentifiers.
Skipping dissectors dir for now.

Change-Id: I717b66bfbc7cc81b83f8c2cbc011fcad643796aa
Reviewed-on: https://code.wireshark.org/review/25694
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-02-08 19:29:45 +00:00
Ahmad Fatoum 9d49e13166 Remove superfluous null-checks before strdup/free
NULL checks were removed for following free functions:

- g_free "If mem is NULL it simply returns"
  https://developer.gnome.org/glib/stable/glib-Memory-Allocation.html#g-free

- g_slist_free(_full)? "NULL is considered to be the empty list"
  https://developer.gnome.org/glib/stable/glib-Singly-Linked-Lists.html

- g_strfreev "If str_array is NULL, this function simply returns."
  https://developer.gnome.org/glib/stable/glib-String-Utility-Functions.html#g-strfreev

- g_slice_free "If mem is NULL, this macro does nothing."
  https://developer.gnome.org/glib/stable/glib-Memory-Slices.html#g-slice-free

- g_match_info_free "not NULL... otherwise does nothing"
  https://developer.gnome.org/glib/stable/glib-Perl-compatible-regular-expressions.html#g-match-info-free

- dfilter_free defined in Wireshark code. Returns early when passed NULL
  epan/dfilter/dfilter.c

They were also removed around calls to g_strdup where applicable:

- g_strdup "If str is NULL it returns NULL."
  https://developer.gnome.org/glib/stable/glib-String-Utility-Functions.html#g-strdup

Change-Id: Ie80c2db89bef531edc3aed7b7c9f654e1d654d04
Reviewed-on: https://code.wireshark.org/review/23406
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: João Valverde <j@v6e.pt>
2017-10-15 12:38:51 +00:00
Pascal Quantin 845835b8db srt_table.c: free table dynamic memory when calling free_srt_table()
Change-Id: I21c259aa0649bcfac5e345f4e41ad1beea0446c1
Reviewed-on: https://code.wireshark.org/review/23455
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-09-11 05:06:26 +00:00
Michael Mann 9e2366a2e5 Don't duplicate memory for key values when passing into wmem_tree_insert_string.
Change-Id: Ib9d8f23faa7a9f83a975396a1be8f85078223feb
Reviewed-on: https://code.wireshark.org/review/20024
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-02-09 00:19:36 +00:00
Michael Mann 89dfa6bdf4 Switch rtd and srt tables to use wmem_tree_t instead of (sorted) GSList.
Change-Id: I54fec10801eb8f359414f34bf705767964c9725e
Reviewed-on: https://code.wireshark.org/review/20017
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-02-08 14:24:42 +00:00
Dario Lombardo 92601c411a srt_table: add cleanup function.
Change-Id: I8d1e9d587f7d47a9064d7b2e0c89f31dc41854ea
Reviewed-on: https://code.wireshark.org/review/19946
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-02-04 01:31:55 +00:00
Michael Mann ab075d3563 Use g_slist_find_custom instead of g_slist_nth when just looking for item in list.
Change-Id: Ida3c5d5826f0ca01a25052a67f1460ff4686008f
Reviewed-on: https://code.wireshark.org/review/19513
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-01-02 23:16:34 +00:00
Dario Lombardo bfb6f62e36 srt: rename shadow variable
Change-Id: I69bda25f79b6b46bdb288e32133847a853b614e0
Reviewed-on: https://code.wireshark.org/review/16101
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-06-26 06:01:22 +00:00
Guy Harris 099698445b Move the proto data stuff out of frame_data.[ch].
It's not tied to the frame_data structure any more, so it belongs by
itself.

Clean up some #includes while we're at it; in particular, frame_data.h
doesn't use anything related to tvbuffs, so don't have it gratuitiously
include tvbuff.h.

Change-Id: Ic32922d4a3840bac47007c5d4c546b8842245e0c
Reviewed-on: https://code.wireshark.org/review/13518
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-01-25 02:24:34 +00:00
Guy Harris a7f470fa24 More pinfo->fd->abs_ts to pinfo->abs_ts.
Change-Id: I70db0a345cc4c5c57c454371deb4f92f9ac4b9ac
Reviewed-on: https://code.wireshark.org/review/13501
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-01-23 03:58:56 +00:00
Guy Harris 18c5496137 Don't cast away constness unnecessarily.
Compare functions for various collection data types don't need to modify
what they're comparing, so keep everything const.

Change-Id: I1c2cff6954b1a8c5ade74943934324d0bd8f523c
Reviewed-on: https://code.wireshark.org/review/12884
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-12-28 20:34:15 +00:00
Michael Mann 7f5717516d Bugfix parsing filters out of SRT tables with parameters.
Change-Id: I5f9315b144333be789f8555f4128371994d4245b
Reviewed-on: https://code.wireshark.org/review/9141
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-06-25 18:42:36 +00:00
Alexis La Goutte 334087b9e4 srt_table: fix conversion shortens 64-bit value into a 32-bit value
Change-Id: I62d04fc2c02c393fd15bccbdfe194c557665dc0e
Reviewed-on: https://code.wireshark.org/review/8999
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2015-06-21 05:42:59 +00:00
Michael Mann 6de6f7f0f8 Further refactor SRT stats.
Create "common" SRT tap data collection intended for all GUIs.   Refactor/merge functionality of existing dissectors that have SRT support (AFP, DCERPC, Diameter, FC, GTP, LDAP, NCP, RPC, SCIS, SMB, and SMB2) for both TShark and GTK.

SMB and DCERPC "tap packet filtering" were different between TShark and GTK, so I went with GTK filter logic.
CAMEL "tap packet filtering" was different between TShark and GTK, so GTK filtering logic was pushed to the dissector and the TShark tap was left alone.

Change-Id: I7d6eaad0673fe628ef337f9165d7ed94f4a5e1cc
Reviewed-on: https://code.wireshark.org/review/8894
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-06-21 03:35:13 +00:00