From 4f67b9db17eea56a96f7ec6012ebbfe701b42f5d Mon Sep 17 00:00:00 2001 From: dogeystamp Date: Mon, 23 May 2022 12:55:56 -0400 Subject: [PATCH] Fix off-by-one memory issue --- minrss.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/minrss.c b/minrss.c index b7e6a4c..c8197a2 100644 --- a/minrss.c +++ b/minrss.c @@ -56,15 +56,16 @@ itemAction(itemStruct *item, const char *folder) memcpy(filePath, folder, folderLen * sizeof(char)); filePath[folderLen] = fsep(); - filePath[pathLen] = '\0'; + filePath[pathLen - 1] = '\0'; memcpy(filePath + folderLen + 1, fileName, fileNameLen * sizeof(char)); - free(fileName); - memcpy(filePath + pathLen - extLen - 1, fileExt, extLen * sizeof(char)); FILE *itemFile = fopen(filePath, "a"); + free(filePath); + free(fileName); + // Do not overwrite files if (!ftell(itemFile)) {