From 4a8da5fbde2b731aeba451735497b46361873282 Mon Sep 17 00:00:00 2001 From: Moshe Kaplan Date: Sun, 15 Mar 2020 13:54:48 -0400 Subject: wslua: Fix crash on TvbRange:__tostring for a zero-length TVB Fields such as 'frame.time_delta' have no byte selection, they are added with offset 0 and length 0, and evidently 'ws_tvb' is NULL. As tvb_bytes_to_str expects a non-NULL tvb, explicitly check for this and add a dummy placeholder. This is intended to be a human-readable string, so prefer `` over an empty string. Change-Id: I32efe4cbefc6bcf0fa9fb94fcf25d7bf1628f3a7 Reviewed-on: https://code.wireshark.org/review/36440 Petri-Dish: Peter Wu Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu --- test/lua/field.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'test') diff --git a/test/lua/field.lua b/test/lua/field.lua index 008a9bc942..9d542cf8e9 100644 --- a/test/lua/field.lua +++ b/test/lua/field.lua @@ -59,6 +59,7 @@ test("Field.new-3",not pcall(makeField,"")) test("Field.new-4",not pcall(makeField,"IP.SRC")) -- declare some field extractors +local f_frame_encap_type = Field.new("frame.encap_type") local f_frame_proto = Field.new("frame.protocols") local f_eth_src = Field.new("eth.src") local f_eth_dst = Field.new("eth.dst") @@ -138,6 +139,7 @@ function tap.packet(pinfo,tvb) test("FieldInfo.range-1", eth_src1 == eth_src2) test("FieldInfo.range-2", eth_src1 == eth_src3) test("FieldInfo.range-3",not pcall(setFieldInfo,fi_eth_src,"range",3)) + test("FieldInfo.range-4", tostring(f_frame_encap_type().range) == "") test("FieldInfo.generated-1", f_frame_proto().generated == true) test("FieldInfo.generated-2", eth_macs[2].generated == false) -- cgit v1.2.3