From: Jo-Philipp Wich Date: Thu, 3 Jul 2014 08:52:48 +0000 (+0200) Subject: options: fix fw3_parse_network() when destination pointer is not a list X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=7db01c8b2fda897c596ee7befbead66c31285590;p=oweals%2Ffirewall3.git options: fix fw3_parse_network() when destination pointer is not a list Signed-off-by: Jo-Philipp Wich --- diff --git a/options.c b/options.c index e864db7..25668fc 100644 --- a/options.c +++ b/options.c @@ -329,7 +329,7 @@ bool fw3_parse_network(void *ptr, const char *val, bool is_list) { struct fw3_device dev = { }; - struct fw3_address *addr; + struct fw3_address *addr, *tmp; LIST_HEAD(addr_list); if (!fw3_parse_address(ptr, val, is_list)) @@ -343,7 +343,19 @@ fw3_parse_network(void *ptr, const char *val, bool is_list) addr->invert = dev.invert; addr->resolved = true; } - list_splice_tail(&addr_list, ptr); + + if (is_list) + { + list_splice_tail(&addr_list, ptr); + } + else if (!list_empty(&addr_list)) + { + memcpy(ptr, list_first_entry(&addr_list, typeof(*addr), list), + sizeof(*addr)); + + list_for_each_entry_safe(addr, tmp, &addr_list, list) + free(addr); + } } return true;