aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--block.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/block.c b/block.c
index 0f8ad7bce2..07309541f3 100644
--- a/block.c
+++ b/block.c
@@ -191,8 +191,12 @@ void get_tmp_filename(char *filename, int size)
void get_tmp_filename(char *filename, int size)
{
int fd;
+ char *tmpdir;
/* XXX: race condition possible */
- pstrcpy(filename, size, "/tmp/vl.XXXXXX");
+ tmpdir = getenv("TMPDIR");
+ if (!tmpdir)
+ tmpdir = "/tmp";
+ snprintf(filename, size, "%s/vl.XXXXXX", tmpdir);
fd = mkstemp(filename);
close(fd);
}