aboutsummaryrefslogtreecommitdiffstats
path: root/epan/wslua/wslua_proto.c
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2016-04-17 21:22:13 +0200
committerPeter Wu <peter@lekensteyn.nl>2016-04-17 21:11:23 +0000
commita9ba46856cff3ec121db5ce883defbec2d1dabd4 (patch)
treeff806bcecd37b58ac99f484a6df2dfa8689eafc9 /epan/wslua/wslua_proto.c
parent558bb1c295187d012fe59ab7e1c24a16cfcbc294 (diff)
wslua: fix crash on Lua errors in dissect_tcp_pdus get_len_func
A similar problem was addressed in v1.99.10rc0-339-g82b2258, but that patch missed the get_pdu_len function. A crash could occur when get_pdu_len does not return a number or when it raises a Lua error. Change-Id: I1a42a95d88708ae3bf6e015ba8d7af4db5071a00 Reviewed-on: https://code.wireshark.org/review/14954 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Diffstat (limited to 'epan/wslua/wslua_proto.c')
-rw-r--r--epan/wslua/wslua_proto.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/epan/wslua/wslua_proto.c b/epan/wslua/wslua_proto.c
index d161ec003c..1bfacbb831 100644
--- a/epan/wslua/wslua_proto.c
+++ b/epan/wslua/wslua_proto.c
@@ -760,6 +760,7 @@ static guint
wslua_dissect_tcp_get_pdu_len(packet_info *pinfo, tvbuff_t *tvb,
int offset, void *data)
{
+ /* WARNING: called from a TRY block, do not call luaL_error! */
func_saver_t* fs = (func_saver_t*)data;
lua_State* L = fs->state;
int pdu_len = 0;
@@ -774,7 +775,7 @@ wslua_dissect_tcp_get_pdu_len(packet_info *pinfo, tvbuff_t *tvb,
lua_pushinteger(L,offset);
if ( lua_pcall(L,3,1,0) ) {
- luaL_error(L, "Lua Error in dissect_tcp_pdus get_len_func: %s", lua_tostring(L,-1));
+ THROW_LUA_ERROR("Lua Error in dissect_tcp_pdus get_len_func: %s", lua_tostring(L,-1));
} else {
/* if the Lua dissector reported the consumed bytes, pass it to our caller */
if (lua_isnumber(L, -1)) {
@@ -782,12 +783,12 @@ wslua_dissect_tcp_get_pdu_len(packet_info *pinfo, tvbuff_t *tvb,
pdu_len = wslua_togint(L, -1);
lua_pop(L, 1);
} else {
- luaL_error(L,"Lua Error dissect_tcp_pdus: get_len_func did not return a Lua number of the PDU length");
+ THROW_LUA_ERROR("Lua Error dissect_tcp_pdus: get_len_func did not return a Lua number of the PDU length");
}
}
} else {
- luaL_error(L,"Lua Error in dissect_tcp_pdus: did not find the get_len_func dissector");
+ REPORT_DISSECTOR_BUG("Lua Error in dissect_tcp_pdus: did not find the get_len_func dissector");
}
return pdu_len;