From 99ac4720957199d82d509205c746bfd9771c9105 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Tue, 10 Mar 2015 12:10:50 +1100 Subject: [PATCH] Honour the proper unix environment variable for temporary directory and then try variations --- lrzip.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lrzip.c b/lrzip.c index 92634db..54047fb 100644 --- a/lrzip.c +++ b/lrzip.c @@ -1262,10 +1262,17 @@ bool initialise_control(rzip_control *control) if (unlikely(!get_rand(control, control->salt + 2, 6))) return false; - /* Get Temp Dir */ - eptr = getenv("TMP"); - if (eptr != NULL) { + /* Get Temp Dir. Try variations on canonical unix environment variable */ + eptr = getenv("TMPDIR"); + if (!eptr) + eptr = getenv("TMP"); + if (!eptr) + eptr = getenv("TEMPDIR"); + if (!eptr) + eptr = getenv("TEMP"); + if (!eptr) { size_t len = strlen(eptr); + control->tmpdir = malloc(len+2); if (control->tmpdir == NULL) fatal_return(("Failed to allocate for tmpdir\n"), false);