Wireshark-dev: [Wireshark-dev] RFD: Limiting scope of ep_ memory
From: Jakub Zawadzki <darkjames-ws@xxxxxxxxxxxx>
Date: Thu, 11 Oct 2012 22:41:51 +0200
Hi,

Right now ep_ memory is freed at the begining of epan_dissect_run(),
which means that pointers allocated by ep_ can be safety accessed only before
dissecting next packet.

When using GUI epan_dissect_run() can be run when refreshing interface (think: packet list).
Which can happen at *any* time. Originally it caused bug #5284.

Right now we (I and Evan) can't reproduce this bug, but there's still the problem.


To make it reproductable (and clear) I want to make ep_ memory available
*only* when dissecting packet, i.e.

epan_dissect_run():
  ep_free_all();
  dissect_packet(edt, pseudo_header, data, fd, cinfo);
  ep_free_all();

Taps also use ep_ memory, so I propose new function:

epan_dissect_run_tap():
  ep_free_all();
  tap_queue_init(edt);
  dissect_packet(edt, pseudo_header, data, fd, cinfo);
  tap_push_tapped_queue(edt);
  ep_free_all();

(For now I want to have ep_free_all() before and after dissecting, before release we
 can remove the one before).

Thanks to it, and memory scrubbing, any ep_ allocated pointer used after dissecting
should be catched fast.

It'll be no longer possible to save ep_ pointers in taps [1], or
communicate with UI by storing ep_ memory in packet_info.


I hope this proposal is understable and sane.
If we want to allow using ep_ memory between epan_dissect_init() and epan_dissect_cleanup() 
we need more complicated allocator, which we currently don't have.
It's doable, but I'm not sure if really needed.

Regards,
 Jakub.

[1] http://www.wireshark.org/lists/wireshark-dev/201210/msg00094.html