aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2024-11-27 02:01:57 +0100
committerMarkus Uhlin <markus@nifty-networks.net>2024-11-27 02:01:57 +0100
commit3db7d9bd54c84ac36b83d7061228866b4634b22c (patch)
tree3dc7f0e718f7f50674cfb6e3b2d70552fdddcc91
parent3c7d144edd00ecfc0fa542fa99fb7e4fd34cc117 (diff)
add_item: check retval of fgets and use sizeof
-rw-r--r--FICS/adminproc.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/FICS/adminproc.c b/FICS/adminproc.c
index ac88afa..bbb0c24 100644
--- a/FICS/adminproc.c
+++ b/FICS/adminproc.c
@@ -221,9 +221,8 @@ add_item(char *new_item, char *filename)
goto end;
while (1) {
- fgets(junk, MAX_LINE_SIZE, old_fp);
-
- if (feof(old_fp))
+ if (fgets(junk, sizeof junk, old_fp) == NULL ||
+ feof(old_fp))
break;
fprintf(new_fp, "%s", junk);
}