diff options
author | Martin Kaiser <wireshark@kaiser.cx> | 2018-09-02 14:43:40 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2018-09-03 04:08:21 +0000 |
commit | 8681e1deba5fc03146125f33722d2094afd02b7f (patch) | |
tree | 41e821c543b8be7b0e81bd8b236e0200ccdd8c94 /epan/packet.c | |
parent | 65b342f7497825c2abc4e98c7fd9f4ff6d8ed45c (diff) |
make IPv4 and IPv6 name resolution usable at all times
IPv4 and v6 name resolution are bound to a capture file. Using a lua
script, it is possible to trigger a name resolution when no capture file
is open. This crashes Wireshark as the hash tables for name resolution
are not initialized at this time.
martin@reykholt:~/src/wireshark.git/build$ echo "print(Address.ip(\"1.1.1.1\"))" > bla.lua
martin@reykholt:~/src/wireshark.git/build$ ./run/tshark -Xlua_script:bla.lua
Segmentation fault
martin@reykholt:~/src/wireshark.git/build$ echo "print(Address.ipv6(\"::1\"))" > bla6.lua
martin@reykholt:~/src/wireshark.git/build$ ./run/tshark -Xlua_script:bla6.lua
Segmentation fault
Make sure that the hash tables are available as long as the epan library
is initialized. Add a new function host_name_lookup_reset(), call this
function every time we set up dissection for a new capture file. This
way, we keep the name resolution results separate per capture file.
Reorder the steps in init_dissection(). Host name lookup is now
available at all times, there's no need to be in file scope when it's
initialized.
Change-Id: I9599100d5f378b6a0f73dc630e4c8af3b3ffb2cc
Reviewed-on: https://code.wireshark.org/review/29398
Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
Petri-Dish: Martin Kaiser <wireshark@kaiser.cx>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/packet.c')
-rw-r--r-- | epan/packet.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/epan/packet.c b/epan/packet.c index d568f37e10..a63cbf6a34 100644 --- a/epan/packet.c +++ b/epan/packet.c @@ -300,13 +300,14 @@ register_shutdown_routine(void (*func)(void)) void init_dissection(void) { - wmem_enter_file_scope(); - /* - * Reinitialize resolution information. We do initialization here in - * case we need to resolve between captures. + * Reinitialize resolution information. Don't leak host entries from + * one file to another (e.g. embarassing-host-name.example.com from + * file1.pcapng into a name resolution block in file2.pcapng). */ - host_name_lookup_init(); + host_name_lookup_reset(); + + wmem_enter_file_scope(); /* Initialize the table of conversations. */ epan_conversation_init(); @@ -336,10 +337,11 @@ cleanup_dissection(void) wmem_leave_file_scope(); /* - * Reinitialize resolution information. We do initialization here in - * case we need to resolve between captures. + * Keep the name resolution info around until we start the next + * dissection. Lua scripts may potentially do name resolution at + * any time, even if we're not dissecting and have no capture + * file open. */ - host_name_lookup_cleanup(); } void |