diff --git a/epan/wslua/wslua_tvb.c b/epan/wslua/wslua_tvb.c index 2ea8862c4c..43e9401f95 100644 --- a/epan/wslua/wslua_tvb.c +++ b/epan/wslua/wslua_tvb.c @@ -338,6 +338,7 @@ WSLUA_CLASS_DEFINE(TvbRange,FAIL_ON_NULL("TvbRange")); A <> represents a usable range of a <> and is used to extract data from the <> that generated it. <>s are created by calling a <> (e.g. 'tvb(offset,length)'). + A length of -1, which is the default, means to use the bytes up to the end of the <>. If the <> span is outside the <>'s range the creation will cause a runtime error. */ @@ -374,6 +375,9 @@ gboolean push_TvbRange(lua_State* L, tvbuff_t* ws_tvb, int offset, int len) { luaL_error(L,"out of bounds"); return FALSE; } + } else if (len < -1) { + luaL_error(L, "negative length in tvb range"); + return FALSE; } else if ( (guint)(len + offset) > tvb_captured_length(ws_tvb)) { luaL_error(L,"Range is out of bounds"); return FALSE;