diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2025-03-09 17:02:41 +0100 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2025-03-09 17:02:41 +0100 |
commit | b06f61a3a513c5cfdd1eebba2743838d2e50b440 (patch) | |
tree | 21714878fd70c887617e93b3b2cead6c4c7ddf0e /FICS/utils.c | |
parent | 253bcca39d3b942b7f5a4e5a26a81419671726eb (diff) |
truncate_file: fixed null ptr dereference
Diffstat (limited to 'FICS/utils.c')
-rw-r--r-- | FICS/utils.c | 7 |
1 files changed, 6 insertions, 1 deletions
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); |