read string: fix out of bound bug

When the bytestring we were about to copy was at the end of the TVB,
we were outrunning the original buffer by trying to read "size + 1".

Stopping the read at size, then expending the newly created bytestring
instead.
This commit is contained in:
Félix Baylac Jacqué 2023-09-15 14:16:44 +02:00
parent 2f0b6c24d8
commit 05585f85fc
1 changed files with 2 additions and 1 deletions

View File

@ -169,7 +169,8 @@ function read_string(tvb, pinfo, tree, offset)
-- Note: the offset indexes the original tvb, not the
-- temporarily created one. There's no need to take this new
-- null bit into account.
local tvb_clone = tvb:bytes(offset, size + 1)
local tvb_clone = tvb:bytes(offset, size)
tvb_clone:set_size(size + 1)
tvb_clone:set_index(size, 0)
str = tvb_clone(0,size+1):tvb():range(0,size+1):string()
offset = offset + size