From 7e53747509cc8521e47641073754dfdcd2d1c798 Mon Sep 17 00:00:00 2001 From: Rafael Rivera Date: Mon, 3 May 2021 12:31:52 -0700 Subject: [PATCH] Fallback onto TEMP if TMPDIR undefined (#441) --- misc.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/misc.c b/misc.c index 36c221ed7..8bed8fc78 100644 --- a/misc.c +++ b/misc.c @@ -1739,7 +1739,15 @@ mktemp_proto(char *s, size_t len) const char *tmpdir; int r; - if ((tmpdir = getenv("TMPDIR")) != NULL) { + tmpdir = getenv("TMPDIR"); + +#ifdef WINDOWS + if (tmpdir == NULL) { + tmpdir = getenv("TEMP"); + } +#endif + + if (tmpdir != NULL) { r = snprintf(s, len, "%s/ssh-XXXXXXXXXXXX", tmpdir); if (r > 0 && (size_t)r < len) return;