URL: https://code.wireshark.org/review/gitweb?p=wireshark.git;a=commit;h=31aba351e206b31bd82614f6402f4a1de5f4c1b3
Submitter: "Anders Broman <a.broman58@xxxxxxxxx>"
Changed: branch: master
Repository: wireshark
Commits:
31aba35 by Peter Wu (peter@xxxxxxxxxxxxx):
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@xxxxxxxxxxxxx>
Tested-by: Petri Dish Buildbot
Reviewed-by: Vasil Velichkov <vvvelichkov@xxxxxxxxx>
Reviewed-by: Anders Broman <a.broman58@xxxxxxxxx>
Actions performed:
from 66345f0 Fix memory ownership when using cf_get_packet_comment
add 31aba35 wiretap: fix memleaks with wtap_rec::opt_comment
Summary of changes:
editcap.c | 3 ++-
epan/wslua/wslua_dumper.c | 5 +++++
epan/wslua/wslua_frame_info.c | 1 +
ui/tap_export_pdu.c | 3 +++
wiretap/erf.c | 6 ++++--
wiretap/nettrace_3gpp_32_423.c | 2 ++
wiretap/pcapng.c | 3 +++
wiretap/wtap.c | 2 ++
8 files changed, 22 insertions(+), 3 deletions(-)