From 88dcc70b71f3ff099d766abd659788988f322208 Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee Date: Sun, 31 Dec 2023 00:31:22 +0000 Subject: [PATCH] Exit gracefully if conf.intf.ifname does not exist horst will only work if there is a wlan interface. But if any user tries horst on a system where there is no wifi hardware then it results in a segfault. As an added benifit this will also protect the user against any misconfiguration of the wlan interface name. The segfault has been reported in Ubuntu. Signed-off-by: Sudip Mukherjee --- main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main.c b/main.c index 28d02a4..7ce49db 100644 --- a/main.c +++ b/main.c @@ -612,6 +612,10 @@ int main(int argc, char** argv) conf.intf.sock = net_open_client_socket(conf.serveraddr, conf.port); cc_list_head_init(&conf.intf.wlan_nodes); } else { + if (!netdev_check_if_exists(conf.intf.ifname)) { + fprintf(stderr, "invalid interface name, please check configuration\n"); + return(-EINVAL); + } ifctrl_init(); ifctrl_iwget_interface_info(&conf.intf);