Skip to content

Commit

Permalink
Fix #144
Browse files Browse the repository at this point in the history
malloc() call doesn't zero-ed allocated memory, resulting in appending `thePath` to some garbage in strncat(). It's better to use strncpy()
  • Loading branch information
SchrodingersMind authored Aug 24, 2022
1 parent adacaac commit 94bff40
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/pdfalto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -473,4 +473,4 @@ void removeAlreadyExistingData(GString *dir) {
if (file) delete file;
closedir(rep);
}
}
}

0 comments on commit 94bff40

Please sign in to comment.