diff --git a/conf.c b/conf.c index 92adea1..c77f09c 100644 --- a/conf.c +++ b/conf.c @@ -204,9 +204,11 @@ static void parse_global_module(char *content, conf * conf) } if (strcasecmp(var, "CLAMAV_ARG") == 0) { val_begin_len = val_end - val_begin; - conf->CLAMAV_TIME_LEN = val_begin_len; + conf->CLAMAV_ARG_LEN = val_begin_len; if (copy_new_mem(val_begin, val_begin_len, &conf->CLAMAV_ARG) != 0) return; + } else { + conf->CLAMAV_ARG_LEN = 0; } // 磁盘使用率 @@ -260,8 +262,10 @@ void read_conf(char *filename, conf * configure) int return_val; file = fopen(filename, "r"); - if (file == NULL) + if (file == NULL) { perror("cannot open config file."); + return ; + } fseek(file, 0, SEEK_END); file_size = ftell(file); buff = (char *)alloca(file_size + 1); diff --git a/conf.h b/conf.h index 1eb768a..62e9309 100644 --- a/conf.h +++ b/conf.h @@ -23,6 +23,7 @@ typedef struct CONF char *CLAMAV_TIME; int CLAMAV_TIME_LEN; char *CLAMAV_ARG; + int CLAMAV_ARG_LEN; int IS_BLOCKED; int REFUSE_NUMBER; diff --git a/rhost.c b/rhost.c index c0e660e..1f4f5fe 100644 --- a/rhost.c +++ b/rhost.c @@ -957,6 +957,12 @@ int main(int argc, char *argv[], char **env) read_conf(path, conf); //ptintf_conf(conf); + if (0 == conf->CLAMAV_ARG_LEN) + { + printf("\033[31mError reading configuration file, please check the configuration file!\033[0m\n"); + + exit(-1); + } // 更新病毒库 update_freshclam(argc, argv);