Fallback onto TEMP if TMPDIR undefined (#441)

This commit is contained in:
Rafael Rivera 2021-05-03 12:31:52 -07:00 committed by GitHub
parent 507b4e52be
commit 7e53747509
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 1 deletions

10
misc.c
View File

@ -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;