From 94bff40f4198c60eda7a71f9887fa4f3373b37a3 Mon Sep 17 00:00:00 2001 From: SchrodingersMind <53609030+SchrodingersMind@users.noreply.github.com> Date: Wed, 24 Aug 2022 16:34:20 +0300 Subject: [PATCH] Fix #144 malloc() call doesn't zero-ed allocated memory, resulting in appending `thePath` to some garbage in strncat(). It's better to use strncpy() --- src/pdfalto.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pdfalto.cc b/src/pdfalto.cc index 0a22164..783b1d6 100644 --- a/src/pdfalto.cc +++ b/src/pdfalto.cc @@ -187,7 +187,7 @@ int main(int argc, char *argv[]) { char *dirname; dirname = (char*)malloc(dirname_length + 1); - strncat(dirname, thePath, dirname_length); + strncpy(dirname, thePath, dirname_length); dirname[dirname_length] = '\0'; // set the config file path as alongside the executable @@ -473,4 +473,4 @@ void removeAlreadyExistingData(GString *dir) { if (file) delete file; closedir(rep); } -} \ No newline at end of file +}