wireshark/epan/wslua
Peter Wu 31aba351e2 wiretap: fix memleaks with wtap_rec::opt_comment
The memory ownership of wtap_rec::opt_comment was not clear. Users of
wtap were leaking memory (editcap.c). wtap readers were not sure about
freeing old comments (erf) or simply ignored memleaks (pcapng).

To fix this, ensure opt_comment is owned by wtap_rec and free it with
wtap_rec_cleanup. The erf issue was already addressed since
cf_get_packet_comment properly duplicates wth.opt_comment memory.

- wtap file formats (readers):
  - Should allocate memory for new comments.
  - Should free a comment from an earlier read before writing a new one.
- Users of wth:
  - Can only assume that opt_comment remains valid until the next read.
  - Can assume that wtap_dump does not modify the comment.
  - For random access (wtap_seek_read): should call wtap_rec_cleanup
    to free the comment.

The test_tshark_z_expert_comment and test_text2pcap_sip_pcapng tests now
pass when built with ASAN.

This change was created by carefully looking at all users opt
"opt_comment" and cf_get_packet_comment. Thanks to Vasil Velichkov for
an initial patch which helped validating this version.

Bug: 7515
Change-Id: If3152d1391e7e0d9860f04f3bc2ec41a1f6cc54b
Reviewed-on: https://code.wireshark.org/review/31713
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Vasil Velichkov <vvvelichkov@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-01-25 04:53:10 +00:00
..
.editorconfig
CMakeLists.txt CMake: Simplify CMAKE_INSTALL_DATADIR usage 2018-12-03 22:35:37 +00:00
console.lua Lua: remove various logging functions (debug, warn, etc.) 2018-09-07 04:02:45 +00:00
dtd_gen.lua epan: more SPDX convertions. 2018-02-09 14:41:31 +00:00
init_wslua.c wslua: fix source argument in debug info for luacov 2018-09-07 04:02:25 +00:00
init_wslua.h epan: Remove unnecessary all protocols registration callback 2018-08-29 23:22:44 +00:00
lrexlib.c spdx: more licenses converted. 2018-03-09 04:50:23 +00:00
lrexlib.h spdx: more licenses converted. 2018-03-09 04:50:23 +00:00
lrexlib_algo.h spdx: more licenses converted. 2018-03-09 04:50:23 +00:00
lrexlib_glib.c spdx: more licenses converted. 2018-03-07 15:56:44 +00:00
lrexlib_glib_f.c spdx: more licenses converted. 2018-03-07 15:56:44 +00:00
lua_bitop.c Revert "Some older compilers don't allow diagnostic pragmas inside a function." 2018-09-12 16:29:30 +00:00
lua_bitop.h spdx: more licenses converted. 2018-03-09 04:50:23 +00:00
make-init-lua.pl wslua: Add support for base.RANGE_STRING handling. 2018-10-17 20:08:57 +00:00
make-reg.pl spdx: more licenses converted. 2018-03-07 15:56:44 +00:00
make-taps.pl spdx: more licenses converted. 2018-03-07 15:56:44 +00:00
taps Rename packet-ssl* to packet-tls* 2018-09-25 13:24:17 +00:00
template-init.lua Revert "Add routines to load Lua programs that assume the path is UTF-8 on Windows." 2018-12-30 07:49:22 +00:00
wslua.h wslua: register attributes along with their class 2019-01-21 11:51:01 +00:00
wslua_address.c lua: add support for ethernet addresses to the Address class 2018-10-18 07:51:36 +00:00
wslua_byte_array.c epan: Guard g_base64_decode_inplace() against zero length string 2018-09-05 17:19:42 +00:00
wslua_capture_info.c wslua: register attributes along with their class 2019-01-21 11:51:01 +00:00
wslua_column.c wslua: use SPDX identifiers. 2018-02-09 12:31:21 +00:00
wslua_dir.c wslua: fix memleak in Dir.remove_all on error path 2018-05-10 06:16:19 +00:00
wslua_dissector.c wslua: Convert more comment markup to Asciidoctor. 2018-02-11 17:12:52 +00:00
wslua_dumper.c wiretap: fix memleaks with wtap_rec::opt_comment 2019-01-25 04:53:10 +00:00
wslua_field.c wslua: register attributes along with their class 2019-01-21 11:51:01 +00:00
wslua_file.c wslua: register attributes along with their class 2019-01-21 11:51:01 +00:00
wslua_file_common.c wslua: use SPDX identifiers. 2018-02-09 12:31:21 +00:00
wslua_file_common.h wslua: use SPDX identifiers. 2018-02-09 12:31:21 +00:00
wslua_file_handler.c wslua: register attributes along with their class 2019-01-21 11:51:01 +00:00
wslua_frame_info.c wiretap: fix memleaks with wtap_rec::opt_comment 2019-01-25 04:53:10 +00:00
wslua_gui.c Try to discourage the use of APIs via counting. 2018-09-19 16:07:03 +00:00
wslua_int64.c spdx: more licenses converted. 2018-03-09 04:50:23 +00:00
wslua_internals.c wslua: register attributes along with their class 2019-01-21 11:51:01 +00:00
wslua_listener.c wslua: register attributes along with their class 2019-01-21 11:51:01 +00:00
wslua_nstime.c wslua: register attributes along with their class 2019-01-21 11:51:01 +00:00
wslua_pinfo.c wslua: register attributes along with their class 2019-01-21 11:51:01 +00:00
wslua_pinfo_common.h wslua: use SPDX identifiers. 2018-02-09 12:31:21 +00:00
wslua_pref.c Free g_array_free-related memory leaks 2018-05-14 13:44:23 +00:00
wslua_proto.c wslua: register attributes along with their class 2019-01-21 11:51:01 +00:00
wslua_proto_expert.c wslua: use SPDX identifiers. 2018-02-09 12:31:21 +00:00
wslua_proto_field.c wslua: Add support for base.RANGE_STRING handling. 2018-10-17 20:08:57 +00:00
wslua_struct.c spdx: more licenses converted. 2018-03-09 04:50:23 +00:00
wslua_tree.c wslua: register attributes along with their class 2019-01-21 11:51:01 +00:00
wslua_tvb.c Add, and use, "fetch signed value" for lengths < 40 bits. 2018-04-10 14:55:45 +00:00
wslua_util.c Revert "Add routines to load Lua programs that assume the path is UTF-8 on Windows." 2018-12-30 07:49:22 +00:00