Skip to content

Commit

Permalink
Honour the proper unix environment variable for temporary directory a…
Browse files Browse the repository at this point in the history
…nd then try variations
  • Loading branch information
ckolivas committed Mar 10, 2015
1 parent 8551a43 commit 99ac472
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lrzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 99ac472

Please sign in to comment.