aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2014-07-08 13:24:25 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2014-07-08 13:24:25 +0200
commita32f6b008aafedd289a79947d08d304e9aaad57a (patch)
treeeb4a67a8bbdcff7d8e03e1fe2c551667c94c00ac
parent936d5f139f0450ab1d6af96b5d91a776483e0455 (diff)
downloadcalcurse-a32f6b008aafedd289a79947d08d304e9aaad57a.tar.gz
calcurse-a32f6b008aafedd289a79947d08d304e9aaad57a.zip
Make sure that tmppath is always NULL-terminated
Fixes GitHub issue #5. Reported-by: dcb314 Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
-rw-r--r--src/config.c4
-rw-r--r--src/note.c1
2 files changed, 3 insertions, 2 deletions
diff --git a/src/config.c b/src/config.c
index da6b049..5eb526a 100644
--- a/src/config.c
+++ b/src/config.c
@@ -600,8 +600,8 @@ unsigned config_save(void)
return 1;
strncpy(tmppath, get_tempdir(), BUFSIZ);
- strncat(tmppath, "/" CONF_PATH_NAME ".",
- BUFSIZ - strlen(tmppath) - 1);
+ tmppath[BUFSIZ - 1] = '\0';
+ strncat(tmppath, "/" CONF_PATH_NAME ".", BUFSIZ - strlen(tmppath) - 1);
if ((tmpext = new_tempfile(tmppath, TMPEXTSIZ)) == NULL)
return 0;
strncat(tmppath, tmpext, BUFSIZ - strlen(tmppath) - 1);
diff --git a/src/note.c b/src/note.c
index a6e48d7..9bce762 100644
--- a/src/note.c
+++ b/src/note.c
@@ -83,6 +83,7 @@ void edit_note(char **note, const char *editor)
FILE *fp;
strncpy(tmppath, get_tempdir(), BUFSIZ);
+ tmppath[BUFSIZ - 1] = '\0';
strncat(tmppath, "/calcurse-note.", BUFSIZ - strlen(tmppath) - 1);
if ((tmpext = new_tempfile(tmppath, TMPEXTSIZ)) == NULL)
return;