--- libaitcfg/src/parse.c 2021/11/26 01:15:03 1.19 +++ libaitcfg/src/parse.c 2022/12/05 22:31:12 1.20 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: parse.c,v 1.19 2021/11/26 01:15:03 misho Exp $ +* $Id: parse.c,v 1.20 2022/12/05 22:31:12 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -69,7 +69,8 @@ cfgReadConfig(FILE *f, cfg_root_t * __restrict cfg) while (!feof(f)) { memset(line, 0, sizeof line); - fgets(line, sizeof line - 1, f); + if (!fgets(line, sizeof(line) - 1, f)) + break; #ifdef SUPPORT_USER_EOF /* check for user end-of-file */ if (line[0] == '.' && line[1] == '\n') @@ -447,7 +448,8 @@ cfgReadLines(FILE *f, const char *delim, const char *e while (!feof(f)) { psSec = psAttr = psVal = NULL; memset(line, 0, sizeof line); - fgets(line, sizeof line - 1, f); + if (!fgets(line, sizeof(line) - 1, f)) + break; /* check for user end-of-file */ if (strspn(line, end)) break;