forked from osmocom/wireshark
sshdump,ciscodump: fix local addresses discovery
Fixes a NULL-deref when no interface addresses are discovered. Remove NULL interface from list (an empty GSList is represented by NULL while g_slist_alloc returns a list with a single NULL data). Change-Id: I2eded40bb697e051445a526d1f34d8a50ef9ccd4 Reviewed-on: https://code.wireshark.org/review/14888 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Reviewed-by: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Peter Wu <peter@lekensteyn.nl>
This commit is contained in:
parent
f9b688226a
commit
bee73f5d04
|
@ -110,10 +110,10 @@ static char* interfaces_list_to_filter(GSList* interfaces, unsigned int remote_p
|
|||
g_string_append_printf(filter, "deny tcp host %s any eq %u, deny tcp any eq %u host %s",
|
||||
(char*)interfaces->data, remote_port, remote_port, (char*)interfaces->data);
|
||||
cur = g_slist_next(interfaces);
|
||||
while (cur->next != NULL) {
|
||||
while (cur) {
|
||||
g_string_append_printf(filter, ", deny tcp host %s any eq %u, deny tcp any eq %u host %s",
|
||||
(char*)cur->data, remote_port, remote_port, (char*)cur->data);
|
||||
cur = cur->next;
|
||||
cur = g_slist_next(cur);
|
||||
}
|
||||
g_string_append_printf(filter, ", permit ip any any");
|
||||
}
|
||||
|
|
|
@ -268,9 +268,9 @@ static char* interfaces_list_to_filter(GSList* interfaces, unsigned int remote_p
|
|||
} else {
|
||||
g_string_append_printf(filter, "not ((host %s", (char*)interfaces->data);
|
||||
cur = g_slist_next(interfaces);
|
||||
while (cur->next != NULL) {
|
||||
while (cur) {
|
||||
g_string_append_printf(filter, " or host %s", (char*)cur->data);
|
||||
cur = cur->next;
|
||||
cur = g_slist_next(cur);
|
||||
}
|
||||
g_string_append_printf(filter, ") and port %u)", remote_port);
|
||||
}
|
||||
|
|
|
@ -50,8 +50,6 @@ GSList *local_interfaces_to_list(void)
|
|||
goto end;
|
||||
}
|
||||
|
||||
interfaces = g_slist_alloc();
|
||||
|
||||
for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) {
|
||||
if (ifa->ifa_addr == NULL)
|
||||
continue;
|
||||
|
|
Loading…
Reference in New Issue