aboutsummaryrefslogtreecommitdiffstats
path: root/test/lua
diff options
context:
space:
mode:
authorMoshe Kaplan <me@moshekaplan.com>2020-03-15 13:54:48 -0400
committerPeter Wu <peter@lekensteyn.nl>2020-03-16 22:42:03 +0000
commit4a8da5fbde2b731aeba451735497b46361873282 (patch)
tree2fbf967bfbfb8915c7dc5f7b1160e859868757df /test/lua
parent2b50d124ec511268ff459335744761adeace018d (diff)
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 `<EMPTY>` over an empty string. Change-Id: I32efe4cbefc6bcf0fa9fb94fcf25d7bf1628f3a7 Reviewed-on: https://code.wireshark.org/review/36440 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Diffstat (limited to 'test/lua')
-rw-r--r--test/lua/field.lua2
1 files changed, 2 insertions, 0 deletions
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) == "<EMPTY>")
test("FieldInfo.generated-1", f_frame_proto().generated == true)
test("FieldInfo.generated-2", eth_macs[2].generated == false)