From 97adeb2f04410248281ef340a742d910ec61c69a Mon Sep 17 00:00:00 2001 From: Aether Chen <15167799+chenjunyu19@users.noreply.github.com> Date: Mon, 4 Nov 2024 12:35:34 +0800 Subject: [PATCH 1/3] config: correct ifname length limit Buffer size is not string length. According to the manual, the size of buffer includes the terminating NULL character. --- config.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config.c b/config.c index d3ccbed..eb638d8 100644 --- a/config.c +++ b/config.c @@ -132,13 +132,13 @@ static void parse_one_opt(const char* option, const char* argument) { } else if (ISOPT("password")) { COPY_N_ARG_TO(g_eap_config.password, PASSWORD_MAX_LEN); } else if (ISOPT("nic")) { - COPY_N_ARG_TO(g_prog_config.ifname, IFNAMSIZ); + COPY_N_ARG_TO(g_prog_config.ifname, IFNAMSIZ - 1); } else if (ISOPT("daemonize")) { g_prog_config.daemon_type = atoi(argument) % 4; } else if (ISOPT("pkt-plugin") || ISOPT("module")) { insert_data(&g_prog_config.packet_plugin_list, (void*)argument); } else if (ISOPT("if-impl")) { - COPY_N_ARG_TO(g_prog_config.if_impl, IFNAMSIZ); + COPY_N_ARG_TO(g_prog_config.if_impl, IFNAMSIZ - 1); } else if (ISOPT("save")) { g_prog_config.save_now = 1; } else if (ISOPT("help")) { @@ -160,7 +160,7 @@ static void parse_one_opt(const char* option, const char* argument) { g_prog_config.kill_type = KILL_AND_START; /* 结束其他实例,本实例继续运行 */ } else if (ISOPT("proxy-lan-iface")) { g_proxy_config.proxy_on = 1; - COPY_N_ARG_TO(g_proxy_config.lan_ifname, IFNAMSIZ); + COPY_N_ARG_TO(g_proxy_config.lan_ifname, IFNAMSIZ - 1); } else if (ISOPT("auth-round")) { g_prog_config.auth_round = atoi(argument); } else if (ISOPT("pid-file")) { From 09fcd6a7e550c0c4b8e1bce2db0dc0816115cd92 Mon Sep 17 00:00:00 2001 From: Aether Chen <15167799+chenjunyu19@users.noreply.github.com> Date: Mon, 4 Nov 2024 12:57:12 +0800 Subject: [PATCH 2/3] config: use strndup insted of malloc and strncpy refactor commit 983fd4a5851d4a344fab92666c5cdb83f26b2294 --- config.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/config.c b/config.c index eb638d8..7c4c6eb 100644 --- a/config.c +++ b/config.c @@ -65,10 +65,7 @@ RESULT parse_cmdline_conf_file(int argc, char* argv[]) { PR_ERR("--conf-file必须有一个参数"); return FAILURE; } else { - int _len = strnlen(argv[i + 1], MAX_PATH); - g_prog_config.conffile = (char*)malloc(_len + 1); - strncpy(g_prog_config.conffile, argv[i + 1], _len); - g_prog_config.conffile[_len] = '\0'; + g_prog_config.conffile = strndup(argv[i + 1], MAX_PATH); } } } From 8cd782fa05608a0973b8e34409d0aff55e56ce41 Mon Sep 17 00:00:00 2001 From: Aether Chen <15167799+chenjunyu19@users.noreply.github.com> Date: Sun, 7 Sep 2025 16:22:46 +0800 Subject: [PATCH 3/3] rjv3: fix function declaration --- packet_plugin/rjv3/packet_plugin_rjv3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packet_plugin/rjv3/packet_plugin_rjv3.c b/packet_plugin/rjv3/packet_plugin_rjv3.c index c671c88..612c6f1 100644 --- a/packet_plugin/rjv3/packet_plugin_rjv3.c +++ b/packet_plugin/rjv3/packet_plugin_rjv3.c @@ -345,7 +345,7 @@ void rjv3_save_config(struct _packet_plugin* this) { conf_parser_add_value("max-dhcp-count", my_itoa(PRIV->max_dhcp_count, itoa_buf, 10)); } -static void packet_plugin_rjv3_print_banner() { +static void packet_plugin_rjv3_print_banner(struct _packet_plugin* this) { PR_INFO("\nRJv3 for MiniEAP " VERSION "\n" "V3 校验算法来自 hyrathb@GitHub\n" "Hamster Tian, 2016\n\n");