From 05585f85fc587814792eb424175746001e9993f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Baylac=20Jacqu=C3=A9?= Date: Fri, 15 Sep 2023 14:16:44 +0200 Subject: [PATCH] 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. --- nix-packet.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nix-packet.lua b/nix-packet.lua index 529f088..05299d6 100644 --- a/nix-packet.lua +++ b/nix-packet.lua @@ -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