From b06f61a3a513c5cfdd1eebba2743838d2e50b440 Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Sun, 9 Mar 2025 17:02:41 +0100 Subject: truncate_file: fixed null ptr dereference --- FICS/utils.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'FICS') diff --git a/FICS/utils.c b/FICS/utils.c index ee7b676..05323e5 100644 --- a/FICS/utils.c +++ b/FICS/utils.c @@ -36,6 +36,8 @@ ignored fgets() retvals. Markus Uhlin 24/12/02 Fixed a possible array overrun in truncate_file(). + Markus Uhlin 25/03/09 truncate_file: + fixed null ptr dereference. */ #include "stdinclude.h" @@ -807,7 +809,10 @@ truncate_file(char *file, int lines) fclose(fp); if (trunc) { - fp = fopen(file, "w"); + if ((fp = fopen(file, "w")) == NULL) { + warn("%s: fopen", __func__); + return 1; + } for (i = 0; i < lines; i++) { fputs(tBuf[bptr], fp); -- cgit v1.2.3