Repository : ssh://git@diktynna/alfred On branches: main,main
commit 94b3c4b5744f79743d9bcd7148c86b2776d1ce75 Author: Marek Lindner mareklindner@neomailbox.ch Date: Mon Jul 3 10:43:01 2023 +0200
alfred: receive data with valid source on unix sock without active interface
Signed-off-by: Marek Lindner mareklindner@neomailbox.ch Signed-off-by: Sven Eckelmann sven@narfation.org
94b3c4b5744f79743d9bcd7148c86b2776d1ce75 unix_sock.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/unix_sock.c b/unix_sock.c index ce08a51..e6208ef 100644 --- a/unix_sock.c +++ b/unix_sock.c @@ -108,10 +108,6 @@ static int unix_sock_add_data(struct globals *globals, int len, data_len, ret = -1; struct interface *interface;
- interface = netsock_first_interface(globals); - if (!interface) - goto err; - len = ntohs(push->header.length);
if (len < (int)(sizeof(*push) - sizeof(push->header))) @@ -133,11 +129,26 @@ static int unix_sock_add_data(struct globals *globals, * source addresses. Otherwise the data would not be * synced between primary servers. */ - if (is_valid_ether_addr(data->source)) { + if (is_iface_disabled(globals->net_iface)) { + if (!is_valid_ether_addr(data->source)) + goto err; + + if (globals->opmode != OPMODE_PRIMARY) + goto err; + + } else if (is_valid_ether_addr(data->source)) { + interface = netsock_first_interface(globals); + if (!interface) + goto err; + if (memcmp(data->source, &interface->hwaddr, ETH_ALEN) != 0 && globals->opmode != OPMODE_PRIMARY) goto err; } else { + interface = netsock_first_interface(globals); + if (!interface) + goto err; + memcpy(data->source, &interface->hwaddr, ETH_ALEN); }