diff --git a/config.c b/config.c index d3ccbed..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); } } } @@ -132,13 +129,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 +157,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")) { 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");