URL: https://code.wireshark.org/review/gitweb?p=wireshark.git;a=commit;h=82b225898b677e7a7e0176941ef73c824d761a98
Submitter: Evan Huus (eapache@xxxxxxxxx)
Changed: branch: master
Repository: wireshark
Commits:
82b2258 by Peter Wu (peter@xxxxxxxxxxxxx):
wslua: fix crash when a LUA error is raised in TRY block
The dissect_tcp_pdus function in LUA is passed two LUA functions that
get the PDU length and the dissect a PDU. When one of these functions
fail, a longjmp is made to the the caller of lua_pcall.
This is no problem for the PDU length function, but the PDU dissect
function is wrapped in a TRY/CATCH/ENDTRY block which also uses longjmp
and need to be fully executed. Without doing so, LUA exceptions will
crash on a weird location (except_pop).
Fix the crash by not using luaL_error, but throw dissector errors which
properly breaks out of the tcp_dissect_pdus C function and then convert
it to a LUA error such that the dissector can handle it.
Test with `tshark -X lua_script:crash.lua -r ssl.pcap`:
trivial_proto = Proto("trivial", "Trivial Protocol")
function dissect_foo(tvb, pinfo, tree)
error("triggering a LUA error");
end
function get_pdu_len(tvb, pinfo, tree) return 5; end
function trivial_proto.dissector(tvb, pinfo, tree)
dissect_tcp_pdus(tvb, tree, 5, get_pdu_len, dissect_foo)
end
tcp_table = DissectorTable.get("tcp.port")
tcp_table:add(443, trivial_proto)
It should not crash and will print this:
Lua Error: dissect_tcp_pdus dissect_func: [string "crash.lua"]:3: triggering a LUA error
Change-Id: Ibd079cc5eb3a2e4d2e62ea49a512fa2cc8e561ea
Reviewed-on: https://code.wireshark.org/review/10685
Petri-Dish: Peter Wu <peter@xxxxxxxxxxxxx>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@xxxxxxxxxxxxx>
Reviewed-by: Peter Wu <peter@xxxxxxxxxxxxx>
Reviewed-by: Evan Huus <eapache@xxxxxxxxx>
Actions performed:
from 3182fba bacapp: attempt to fix windows build
adds 82b2258 wslua: fix crash when a LUA error is raised in TRY block
Summary of changes:
epan/exceptions.h | 4 ++++
epan/wslua/wslua.h | 20 ++++++++++++++++++++
epan/wslua/wslua_proto.c | 14 +++++++++-----
3 files changed, 33 insertions(+), 5 deletions(-)