Lua: Segfault when registering a field or expert info twice
Summary
Wireshark segfaults when a protocol field is added twice.
protocol = Proto("proto", "Protocol")
f_field1 = ProtoField.uint32("proto.field1", "Field 1")
protocol.fields = {
f_field1, f_field1
}
udp_table = DissectorTable.get("udp.port")
udp_table:add(8080, protocol)
Steps to reproduce
Store the lua script above in your user script folder, and start Wireshark (or hot reload the lua script with CTRL+SHIFT+L)
What is the current bug behavior?
Segmentation fault
What is the expected correct behavior?
Error message dialog informing the user the lua script is malformed.
Sample capture file
n/a
Relevant logs and/or screenshots
gdb backrace below
Notice the string "fields can be registered only once"
Thread 1 "wireshark" received signal SIGABRT, Aborted.
__pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0)
at pthread_kill.c:44
Downloading source file /usr/src/debug/glibc-2.37-4.fc38.x86_64/nptl/pthread_kill.c
44 return INTERNAL_SYSCALL_ERROR_P (ret) ? INTERNAL_SYSCALL_ERRNO (ret) : 0;
(gdb) bt
#0 __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0)
at pthread_kill.c:44
#1 0x00007fffeeab08b3 in __pthread_kill_internal (signo=6, threadid=<optimized out>) at pthread_kill.c:78
#2 0x00007fffeea5fabe in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3 0x00007fffeea4887f in __GI_abort () at abort.c:79
#4 0x00007fffef8b3200 in log_write_dispatch
(domain=0x7ffff418d89b "", level=LOG_LEVEL_ERROR, file=0x7ffff4c4a1e8 "epan/wslua/init_wslua.c", line=629, func=0x7ffff4c8d908 <__func__.0.lto_priv.114> "wslua_panic", user_format=0x7ffff4c87c56 "LUA PANIC: %s", user_ap=0x7fffffffd1e0) at /usr/src/debug/wireshark-4.0.6-1.fc38.x86_64/wsutil/wslog.c:978
#5 0x00007fffef8c2c43 in ws_log_fatal_full
(domain=domain@entry=0x7ffff418d89b "", level=level@entry=LOG_LEVEL_ERROR, file=file@entry=0x7ffff4c4a1e8 "epan/wslua/init_wslua.c", line=line@entry=629, func=func@entry=0x7ffff4c8d908 <__func__.0.lto_priv.114> "wslua_panic", format=format@entry=0x7ffff4c87c56 "LUA PANIC: %s") at /usr/src/debug/wireshark-4.0.6-1.fc38.x86_64/wsutil/wslog.c:1040
#6 0x00007ffff395d186 in wslua_panic (LS=<optimized out>)
at /usr/src/debug/wireshark-4.0.6-1.fc38.x86_64/epan/wslua/init_wslua.c:629
#7 0x00007fffee2ffaee in luaD_throw (L=0x555555f897e0, errcode=errcode@entry=2)
at /usr/src/debug/compat-lua-5.1.5-22.fc38.x86_64/src/ldo.c:104
#8 0x00007fffee302ba1 in luaG_errormsg (L=<optimized out>)
at /usr/src/debug/compat-lua-5.1.5-22.fc38.x86_64/src/ldebug.c:627
#9 0x00007fffee302bed in lua_error (L=<optimized out>)
at /usr/src/debug/compat-lua-5.1.5-22.fc38.x86_64/src/lapi.c:967
#10 0x00007fffee310ace in luaL_error
(L=L@entry=0x555555f897e0, fmt=fmt@entry=0x7ffff4c8a220 "fields can be registered only once")
at /usr/src/debug/compat-lua-5.1.5-22.fc38.x86_64/src/lauxlib.c:93
#11 0x00007ffff3967601 in Proto_commit (L=0x555555f897e0)
at /usr/src/debug/wireshark-4.0.6-1.fc38.x86_64/epan/wslua/wslua_proto.c:721
#12 wslua_init (cb=<optimized out>, client_data=<optimized out>)
at /usr/src/debug/wireshark-4.0.6-1.fc38.x86_64/epan/wslua/init_wslua.c:1115
#13 0x00007ffff28fa03e in epan_init
(cb=0x5555559f0cb0 <splash_update(register_action_e, char const*, void*)>, client_data=0x0, load_plugins=<optimized out>) at /usr/src/debug/wireshark-4.0.6-1.fc38.x86_64/epan/epan.c:322
#14 0x00005555556c6d2f in main(int, char**) (argc=<optimized out>, qt_argv=0x7fffffffdd28)
at /usr/src/debug/wireshark-4.0.6-1.fc38.x86_64/ui/qt/main.cpp:738
(gdb)
Build information
Version 4.0.6 (Git commit ac2f5a01286a).
Compiled (64-bit) using GCC 13.1.1 20230511 (Red Hat 13.1.1-2), with GLib
2.76.3, with PCRE2, with zlib 1.2.13, with Qt 6.5.0, with libpcap, with POSIX
capabilities (Linux), with libnl 3, with Lua 5.1.5, with GnuTLS 3.8.0 and PKCS
#11 support, with Gcrypt 1.10.2-unknown, with Kerberos (MIT), with MaxMind, with
nghttp2 1.52.0, without brotli, without LZ4, with Zstandard, without Snappy,
without libxml2, with libsmi 0.4.8, with QtMultimedia, without automatic
updates, with SpeexDSP (using bundled resampler), without Minizip, with binary
plugins.
Running on Linux 6.3.11-200.fc38.x86_64, with Intel(R) Core(TM) i7-4702MQ CPU @
2.20GHz (with SSE4.2), with 31742 MB of physical memory, with GLib 2.76.3, with
PCRE2 10.42 2022-12-11, with zlib 1.2.13, with Qt 6.5.1, with libpcap 1.10.4
(with TPACKET_V3), with c-ares 1.19.1, with GnuTLS 3.8.0, with Gcrypt
1.10.2-unknown, with nghttp2 1.52.0, with Zstandard 1.5.5, with libsmi 0.4.8,
with dark display mode, without HiDPI, with LC_TYPE=en_US.UTF-8, binary plugins
supported.
Edited by Maarten