Allocate space for null terminator.
diff --git a/lib/lib.c b/lib/lib.c
index 490235f..ade0786 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -512,8 +512,7 @@
   struct stat statbuf;
   int fd;
 
-  *tempname = xstrndup(name, strlen(name)+6);
-  strcat(*tempname,"XXXXXX");
+  *tempname = xmprintf("%s%s", name, "XXXXXX");
   if(-1 == (fd = mkstemp(*tempname))) error_exit("no temp file");
   if (!tempfile2zap) sigatexit(tempfile_handler);
   tempfile2zap = *tempname;