Commit Graph

82 Commits

Author SHA1 Message Date
João Valverde 39df3ae3c0 Replace g_log() calls with ws_log() 2021-06-16 12:50:27 +00:00
João Valverde e10f761362 wslua: Replace g_assert() with ws_assert() 2021-05-19 03:52:45 +01:00
Gerald Combs e99c9afce8 Be more strict about opening URLs.
In the proto tree, copy URLs instead of opening them.

In the export dialog, enable previews only if the advertised MIME type
*and* the contents of the file are plain text, GIF, JPEG, or PNG.

Add warnings to the wslua browser_open_url and browser_open_data_file
documentation.

Fixes #17232.
2021-02-15 08:47:57 +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
Stig Bjørlykke d104571e8a Lua: Improve Listener error handling
Fix error handlers in Listener draw() and reset() to avoid getting
LUA_ERRERR from lua_pcall(). Added error handler for Listener draw()
callback.

Handle LUA_ERRERR from lua_pcall() to avoid assert on this.
Changed some capitalized words in various error message.

Closes #16974.
2020-12-04 13:38:00 +00:00
Guy Harris e013c5ec7f Clean up URLs.
Add ui/urls.h to define some URLs on various of our websites.  Use the
GitLab URL for the wiki.  Add a macro to generate wiki URLs.

Update wiki URLs in comments etc.

Use the #defined URL for the docs page in
WelcomePage::on_helpLabel_clicked; that removes the last user of
topic_online_url(), so get rid of it and swallow it up into
topic_action_url().
2020-10-02 20:13:42 -07:00
rbroker 1f75d7b3b9 wslua: Add ability to query current temporary color filter text
The LUA API provides the "set_color_filter_slot" function, but without
a corresponding "get_" function, it's very hard for two LUA dissectors
to co-exist without one overwriting any color filters set by the other.

It also looks like the documentation comment for
"set_color_filter_slot" had an off-by-one error, which I've corrected
as I was adding almost identical documentation for the new API.

Change-Id: Ic54d23be555ec12e1830bbe6f84a1b04d04fd4f0
Reviewed-on: https://code.wireshark.org/review/37511
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-06-25 08:02:27 +00:00
Gerald Combs 6f59b8e84d wslua: Cross-reference and title case fixes.
Use lua_class_DissectorTable instead of lua_class_DissectorTables.

Use title case for each module.

Change-Id: Ie855022ee59a857c8ced7c3e6ba070ab494fa017
Reviewed-on: https://code.wireshark.org/review/36634
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2020-03-30 16:42:18 +00:00
Gerald Combs 1a3e64db39 wslua: Update the GUI docs.
Add content from https://wiki.wireshark.org/LuaAPI/GUI and update as
needed.

Separate some of our Asciidoctor output with newlines.

Change-Id: I2b8b9449c94bd69095fbd4b65ea415cd4d525c30
Reviewed-on: https://code.wireshark.org/review/36613
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>
2020-03-30 06:56:44 +00:00
Stig Bjørlykke 8afd7a751f funnel: Free callback data
Free one more allocated callback data in TextWindow. This is needed
because text_win_close_cb() is also doing the same as TextWindow__gc().

Bug: 16177
Change-Id: I7c2211e154a6db1dccd22df824e76cce575040c9
Reviewed-on: https://code.wireshark.org/review/34990
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2019-11-05 17:15:42 +00:00
Stig Bjørlykke 499d912f4b funnel: Free callback data
Free allocated callback data in FunnelStringDialog, TextWindow and
registered menu items. Also free strings used in FunnelStringDialog.

Bug: 16177
Change-Id: I9a129b8975a55d1dc89fe851116feebe82763bca
Reviewed-on: https://code.wireshark.org/review/34945
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-11-05 15:21:30 +00:00
Guy Harris 20800366dd HTTPS (almost) everywhere.
Change all wireshark.org URLs to use https.

Fix some broken links while we're at it.

Change-Id: I161bf8eeca43b8027605acea666032da86f5ea1c
Reviewed-on: https://code.wireshark.org/review/34089
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-07-26 18:44:40 +00:00
Stig Bjørlykke 2b7875b905 wslua: Update wslua_register_menu() documentation
Add missing group values. Update regex to match TELEPHONY_MTP3.

Change-Id: I709a416e30d79c2de69887548015a3c1ecfe5bab
Reviewed-on: https://code.wireshark.org/review/31779
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-01-29 05:47:05 +00:00
Gerald Combs 8f08a4e74e Try to discourage the use of APIs via counting.
Add the ability to specify maximum function counts for each group to
checkAPIs. Add maximum counts for the "termoutput" and "abort" groups
where needed. Show summaries in various checkAPI targets.

Switch uses of ws_g_warning back to plain g_warning.

Change-Id: I5cbddc8c671729e424eed8551f69116d16491976
Reviewed-on: https://code.wireshark.org/review/29721
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2018-09-19 16:07:03 +00:00
Dario Lombardo ff6e2fbb1b wslua: use SPDX identifiers.
Change-Id: I80d9d4e3ffc25eebf09e6ef693c378b77554e1b8
Reviewed-on: https://code.wireshark.org/review/25693
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-02-09 12:31:21 +00:00
Stig Bjørlykke 28ba566675 wslua: Fix memory leakages
Free some variables in error handling.

Change-Id: I0d0653962b11f760c31872aa7e5b5f1d20c54dcb
Reviewed-on: https://code.wireshark.org/review/24842
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-12-16 03:12:00 +00:00
Michael Mann 9bfbffa1c8 Use ws_g_warning in wslua.
The g_warning calls seem legitimate, so "hide" them from checkAPIs.pl.

Change-Id: I6d25b08e22aeeb0244e07836385f2b67d6261546
Reviewed-on: https://code.wireshark.org/review/16703
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-07-26 17:15:26 +00:00
Peter Wu f6e223c895 wslua: Drop unused "push_code" macro parameter
Reduce noise, no caller has used this parameter since its introduction.
Msotly automated regex search and replace.

Change-Id: I4b1180bfee8544b38d19c9c440ff5b9b0dc080b2
Reviewed-on: https://code.wireshark.org/review/14790
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-06-14 18:32:51 +00:00
Stig Bjørlykke ebdaace002 Lua: Added reload_lua_plugins
This makes it possible to trigger reloading Lua plugins from
within a Lua plugin.  This can be used when having a plugin to
update local plugins from a external source.

Renamed reload() to reload_packets() to clarify what's reloaded,
and added a alias (marked as obsoleted) from reload().

Change-Id: I4e529992af5f651613950329e73718dbda317d2e
Reviewed-on: https://code.wireshark.org/review/13024
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2016-01-11 07:43:36 +00:00
Stig Bjørlykke ecc4f756bd Added Reload Lua plugins.
This is initial support for reloading Lua plugins without
restarting the application.

Still todo:
- Deregister FileHandlers
- Support deregister ProtoField with existing abbrev (same_name_hfinfo)
- Add a progress dialog when reloading many plugins
- Search for memory leakages in wslua functions

Change-Id: I48870d8741251705ca15ffe1068613fcb0cb18c1
Reviewed-on: https://code.wireshark.org/review/5028
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2015-08-11 12:09:07 +00:00
Gerald Combs e91ca72a44 Qt: Add initial Lua support.
Add a FunnelStatistics class, which is the main interface between the Qt
UI and the Funnel API.

Add FunnelTextDialog, which implements the text_window, ProgDlg, menu,
and other routines. Add FunnelStringDialog, which implements dlg_new.

We currently only support "Tools" menu items (MENU_TOOLS_UNSORTED, aka
REGISTER_TOOLS_GROUP_UNSORTED). Add a disabled placeholder to the
"Tools" menu in case we don't load any scripts.

Use "struct progdlg" instead of needlessly casting to
funnel_progress_window_t.

To do:
- Add support for MENU_STAT_UNSORTED, MENU_STAT_GENERIC, etc.
- Make the firewall config generator a Lua script?
- Add FunnelGraphDialog? It seems like it would be useful to
  make QCustomPlot accessible to Lua scripts.

Ping-Bug: 9845
Change-Id: Iefff02e9032ed1853666f7902509ed08b431e7a7
Reviewed-on: https://code.wireshark.org/review/9523
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2015-07-07 20:49:30 +00:00
Bill Meier 82f081dd64 wslua*: Add editor modelines; Fix indentation, etc as needed.
Change-Id: I6df5d46f4b263104aa9cb6353cc987087cdb867e
Reviewed-on: https://code.wireshark.org/review/7102
Reviewed-by: Bill Meier <wmeier@newsguy.com>
2015-02-13 18:28:23 +00:00
Guy Harris 19a8eafc15 Use luaL_{check,opt}integer() rather than luaL_{check,opt}int().
Lua prior to 5.3 defined luaL_{check,opt}int() as macros wrapping
luaL_{check,opt}integer() with a cast to int; Lua 5.3 doesn't.

It sounds as if the Lua developers are deprecating luaL_{check,opt}int():

    http://osdir.com/ml/general/2014-10/msg46568.html

Change-Id: I2d0b649dcd57ede124f31d39f7945f342ae9b18f
Reviewed-on: https://code.wireshark.org/review/6744
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com>
Petri-Dish: Hadriel Kaplan <hadrielk@yahoo.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Tested-by: Hadriel Kaplan <hadrielk@yahoo.com>
2015-01-23 03:58:29 +00:00
Guy Harris cfcbb28671 Clean up ftype-conversion and dfilter error message string handling.
Have dfilter_compile() take an additional gchar ** argument, pointing to
a gchar * item that, on error, gets set to point to a g_malloc()ed error
string.  That removes one bit of global state from the display filter
parser, and doesn't impose a fixed limit on the error message strings.

Have fvalue_from_string() and fvalue_from_unparsed() take a gchar **
argument, pointer to a gchar * item, rather than an error-reporting
function, and set the gchar * item to point to a g_malloc()ed error
string on an error.

Allow either gchar ** argument to be null; if the argument is null, no
error message is allocated or provided.

Change-Id: Ibd36b8aaa9bf4234aa6efa1e7fb95f7037493b4c
Reviewed-on: https://code.wireshark.org/review/6608
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-01-18 10:22:59 +00:00
Hadriel Kaplan fac8356610 Make all Lua code use wmem not emem
Changed all remaining code in wslua that was using emem, to use wmem or
simpler methods.

Bug: 9927
Change-Id: I3d19a770e0fd77d996bdb6b61a76a722cc2bcd55
Reviewed-on: https://code.wireshark.org/review/6109
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com>
Petri-Dish: Hadriel Kaplan <hadrielk@yahoo.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-01-04 21:02:38 +00:00
Stig Bjørlykke b653564fe2 Lua: luaL_checkstring does not return NULL
Removed all checks for NULL strings to cleanup the code.

Change-Id: Ia890cd9b206296f586e85214f07765f14984580b
Reviewed-on: https://code.wireshark.org/review/4632
Tested-by: Stig Bjørlykke <stig@bjorlykke.org>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2014-10-13 19:06:40 +00:00
Evan Huus 6e6bd90754 Convert the obvious emem to wmem in lua code.
Bug:9927
Change-Id: Ibf0dd45d3b54e489b70a4fde193b825ec703379e
Reviewed-on: https://code.wireshark.org/review/2349
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-06-18 05:54:28 +00:00
Hadriel Kaplan de441241ef Enhance Lua API doc generator and add more API info
This enhances the Lua API doc generator Perl script to handle
meta-information in description comments, such as bold, italics,
raw code, version info, etc.

The supported markup and codes are documented in make-wsluarm.pl.

It's not beautiful Perl code (I don't know Perl), and I'd rather
do it using Lua, but I think keeping it Perl makes more sense in
the long run.

Change-Id: I477b3ebe770075dcea9ec52708e2d6fb5758d2f4
Reviewed-on: https://code.wireshark.org/review/802
Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-25 05:30:11 +00:00
Alexis La Goutte 296591399f Remove all $Id$ from top of file
(Using sed : sed -i '/^ \* \$Id\$/,+1 d')

Fix manually some typo (in export_object_dicom.c and crc16-plain.c)

Change-Id: I4c1ae68d1c4afeace8cb195b53c715cf9e1227a8
Reviewed-on: https://code.wireshark.org/review/497
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-04 14:27:33 +00:00
Hadriel Kaplan c826191be0 Fix coverity warnings for all wslua files. (redux)
This fixes/addresses all the coverity warnings shown by
the buildbots. (I hope)

Change-Id: Ic2722df97c577d274e3cf3f0cbdca1902edde047
Reviewed-on: https://code.wireshark.org/review/423
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2014-02-27 21:23:09 +00:00
Hadriel Kaplan 9246a709bf Cleanup on aisle 5: normalizes the Lua code to follow common schema/model
Over time the various wslua classes/functions have gotten moldy, with different
ways of doing similar things. Some of it can't be changed without breaking
backwards compatibility for Lua scripts, so I didn't do that. But I did what
I could. The biggest change is a refactoring of how accessors/attributes
are handled in the code, so that most of them work the same way using the
same code.

Specific changes made:
 * Added null/expired checking macro to class declarations for many classes
 * Removed extraneous pointer/expired checking, since checkFoo() does that already
 * Fixed "errors" reported by clang static analyzer; they were false positives, but it was easier to get it to stop complaining by changing the code
 * Moved internal wslua functions from wslua_utils.c into a new 'wslua_internals.c' file
 * Changed Listener/NSTime/Pinfo/Proto to use a common setter/getter accessor/attribute code model, instead of each of them doing their own
 * Fixed some API doc mistakes, mostly around attributes that were documented as read-only but were actually read-write

Change-Id: Idddafc5fbd3545ebff29e063acc767e1c743a1a9
Reviewed-on: https://code.wireshark.org/review/271
Reviewed-by: Evan Huus <eapache@gmail.com>
Tested-by: Evan Huus <eapache@gmail.com>
2014-02-21 02:05:35 +00:00
Hadriel Kaplan 991bd3d7e1 Fix bug 9732: ' Lua: recent commit changed some MENU_ key names in init.lua'
A recent fix (made by me) for bug 9707, in Change-Id:
If4ee1906aa60dd37366cf2ef9bc4168e0ea024b6, made the perl regex grab too much
of the menu name.  It changed MENU_STAT_CONVERSATION, MENU_STAT_RESPONSE, and
MENU_ANALYZE_CONVERSATION's key names into their longer C-code names.  Ugh.

The fix for this is a bit brittle, but I think it's impractical to avoid it
being brittle, due to needing to support legacy Lua scripts.  I put comments
in stat_menu.h to warn of the danger.

Change-Id: I41408e9d4f5b5bd73e2871fccabff81c7cbd242d
Reviewed-on: https://code.wireshark.org/review/140
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2014-02-08 11:29:32 +00:00
Hadriel Kaplan 3d59ff9e95 Fix for Bug-9711 Lua: the Lua stack is growing slightly during initialization.
Change-Id: I689319c0071fdb42583e8bd7633d8f0660c92f1b
Reviewed-on: https://code.wireshark.org/review/51
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Stig Bjørlykke <stig@bjorlykke.org>
2014-01-31 16:31:59 +00:00
Martin Kaiser a0df200a84 coverity 702387
add missing NULL check

svn path=/trunk/; revision=54848
2014-01-19 16:19:24 +00:00
Guy Harris a48d06df11 We have to cast away constness here, because C doesn't have
parameterized types.

svn path=/trunk/; revision=54801
2014-01-14 18:42:16 +00:00
Guy Harris 834c79a07e Don't cast away constness.
svn path=/trunk/; revision=54796
2014-01-14 18:12:14 +00:00
Jörg Mayer f348cd5678 Explicit inclusion of emem.h
svn path=/trunk/; revision=52000
2013-09-13 08:49:38 +00:00
Anders Broman 27744ecc2d From beroset:
remove C++ incompatibilities 
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8416

svn path=/trunk/; revision=48337
2013-03-16 08:12:29 +00:00
Michael Mann 2c7844cc69 Fix typos/errors and make Lua API more consistent.
From Hadriel Kaplan, bug 8393 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8393)

svn path=/trunk/; revision=47885
2013-02-25 22:05:28 +00:00
Guy Harris 80b0bc752e Add a new WSLUA_CLASS_FNREG_ALIAS() macro to register methods where the
function name isn't the same as the method name; this is used if we're
providing compatibility aliases for method names.

Use WSLUA_CLASS_FNREG() and WSLUA_CLASS_FNREG_ALIAS() for all method
registrations.

Fix the spelling of "prepend", but leave a compatibility alias in place.

svn path=/trunk/; revision=47667
2013-02-15 01:38:45 +00:00
Jeff Morriss 3729335973 We always HAVE_CONFIG_H so don't bother checking whether we have it or not.
svn path=/trunk/; revision=45016
2012-09-20 01:48:30 +00:00
Evan Huus dd01cc0490 From Niels Widger via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7725
Add get_filter method to Wireshark's Lua interface (to correspond with the
already-exposed set_filter method).

svn path=/trunk/; revision=44916
2012-09-15 13:58:57 +00:00
Jakub Zawadzki bf81b42e1e Update Free Software Foundation address.
(COPYING will be updated in next commit)

svn path=/trunk/; revision=43536
2012-06-28 22:56:06 +00:00
Anders Broman fec821f303 From Evan Huus:
Fix Three memory leaks and a bad if-condition, as caught by CppCheck.

https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7272

svn path=/trunk/; revision=42738
2012-05-21 07:42:09 +00:00
Jeff Morriss 2d829b392f Line-wrap an extremely long comment. Remove trailing white space.
svn path=/trunk/; revision=41552
2012-03-15 02:33:52 +00:00
Guy Harris cd9fe7e242 Convert 4-space tabs to spaces.
svn path=/trunk/; revision=41441
2012-03-08 20:00:49 +00:00
Stig Bjørlykke 8dd3dc1ef2 From bug 6057:
Improved set_color_filter_slot documentation.

svn path=/trunk/; revision=37813
2011-06-28 09:11:18 +00:00
Stig Bjørlykke b979f2da27 From bug 6057:
Lua API: add support to temporary color filters (10 color slots)

svn path=/trunk/; revision=37801
2011-06-27 11:07:31 +00:00
Stig Bjørlykke 4ac2487d38 From Tony Trinh via bug 6018:
Add NULL checks and fix typos in Lua error print-outs

From me:
Use the error message "GUI not available" when using GUI functions in tshark.

svn path=/trunk/; revision=37788
2011-06-25 20:47:13 +00:00
Jakub Zawadzki 0edf3eafa9 Comment out dead code.
svn path=/trunk/; revision=37029
2011-05-09 12:49:39 +00:00