commit bea2fc990d20498c21f451f82cd929afb9a4dacd
parent a409d1cee63af6d51e36ea00bfdece9f08a49341
Author: Hypsurus <Hypsurus@users.noreply.github.com>
Date: Tue, 13 Oct 2015 19:33:05 +0300
parent a409d1cee63af6d51e36ea00bfdece9f08a49341
Author: Hypsurus <Hypsurus@users.noreply.github.com>
Date: Tue, 13 Oct 2015 19:33:05 +0300
Fix segfault in fopen, no check for null
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/fiche.c b/fiche.c @@ -244,7 +244,11 @@ char *check_whitelist(char *ip_address) void load_list(char *file_path, int type) { - FILE *fp = fopen(file_path, "r"); + FILE *fp; + + if (( fp = fopen(file_path, "r")) == NULL ) + error("cannot load list"); + fseek(fp, 0, SEEK_END); long fsize = ftell(fp); fseek(fp, 0, SEEK_SET);
: nply/fiche2