From 3db7d9bd54c84ac36b83d7061228866b4634b22c Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Wed, 27 Nov 2024 02:01:57 +0100 Subject: add_item: check retval of fgets and use sizeof --- FICS/adminproc.c | 5 ++--- 1 file 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); } -- cgit v1.2.3