wslua_tvb: correctly trim off the end of a tvbuff.

The length specified in a TvbRange is the *actual packet length*, not
the *sliced-to* length, so use tvb_new_subset_length() to cut it short.

This fixes the fix for #15655, and addresses at least some of the issues
in #17255.


(cherry picked from commit cda18f951e)
This commit is contained in:
Guy Harris 2021-03-28 02:31:37 +00:00
parent 6ef6e8f607
commit 193b1fc545
1 changed files with 1 additions and 2 deletions

View File

@ -399,8 +399,7 @@ WSLUA_METHOD TvbRange_tvb(lua_State *L) {
tvb = (Tvb)g_malloc(sizeof(struct _wslua_tvb));
tvb->expired = FALSE;
tvb->need_free = FALSE;
// -1 means recalculate the reported_len based on the new offset
tvb->ws_tvb = tvb_new_subset_length_caplen(tvbr->tvb->ws_tvb,tvbr->offset,tvbr->len,-1);
tvb->ws_tvb = tvb_new_subset_length(tvbr->tvb->ws_tvb,tvbr->offset,tvbr->len);
return push_wsluaTvb(L, tvb);
} else {
luaL_error(L,"Out Of Bounds");