forked from osmocom/wireshark
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>
This commit is contained in:
parent
65b342f749
commit
8681e1deba
|
@ -2890,7 +2890,7 @@ add_manually_resolved(void)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
host_name_lookup_init(void)
|
||||
{
|
||||
char *hostspath;
|
||||
|
@ -2960,7 +2960,7 @@ host_name_lookup_init(void)
|
|||
ss7pc_name_lookup_init();
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
host_name_lookup_cleanup(void)
|
||||
{
|
||||
guint32 i, j;
|
||||
|
@ -2991,6 +2991,13 @@ host_name_lookup_cleanup(void)
|
|||
new_resolved_objects = FALSE;
|
||||
}
|
||||
|
||||
|
||||
void host_name_lookup_reset(void)
|
||||
{
|
||||
host_name_lookup_cleanup();
|
||||
host_name_lookup_init();
|
||||
}
|
||||
|
||||
void
|
||||
manually_resolve_cleanup(void)
|
||||
{
|
||||
|
@ -3468,8 +3475,7 @@ addr_resolv_init(void)
|
|||
initialize_ipxnets();
|
||||
initialize_vlans();
|
||||
initialize_enterprises();
|
||||
/* host name initialization is done on a per-capture-file basis */
|
||||
/*host_name_lookup_init();*/
|
||||
host_name_lookup_init();
|
||||
}
|
||||
|
||||
/* Clean up all the address resolution subsystems in this file */
|
||||
|
@ -3481,8 +3487,7 @@ addr_resolv_cleanup(void)
|
|||
ethers_cleanup();
|
||||
ipx_name_lookup_cleanup();
|
||||
enterprises_cleanup();
|
||||
/* host name initialization is done on a per-capture-file basis */
|
||||
/*host_name_lookup_cleanup();*/
|
||||
host_name_lookup_cleanup();
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
|
|
@ -364,15 +364,9 @@ void set_resolution_synchrony(gboolean synchronous);
|
|||
WS_DLL_LOCAL
|
||||
void name_resolver_init(void);
|
||||
|
||||
/* (Re)Initialize hostname resolution subsystem */
|
||||
/* Reinitialize hostname resolution subsystem */
|
||||
WS_DLL_LOCAL
|
||||
void host_name_lookup_init(void);
|
||||
|
||||
/* Clean up only hostname resolutions (so they don't "leak" from one
|
||||
* file to the next).
|
||||
*/
|
||||
WS_DLL_LOCAL
|
||||
void host_name_lookup_cleanup(void);
|
||||
void host_name_lookup_reset(void);
|
||||
|
||||
WS_DLL_LOCAL
|
||||
void addr_resolv_init(void);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue