Skip to content

Commit 35c3c62

Browse files
Holger EitzenbergerJunio C Hamano
authored andcommitted
[PATCH] git_mkstemp() fix
git_mkstemp() attempted to use TMPDIR environment variable, but it botched copying the templates. [jc: Holger, please add your own Signed-off-by line, and also if you can, send in future patches as non attachments.] Signed-off-by: Junio C Hamano <[email protected]>
1 parent affa40d commit 35c3c62

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

path.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,13 @@ int git_mkstemp(char *path, size_t len, const char *template)
6868
if ((env = getenv("TMPDIR")) == NULL) {
6969
strcpy(pch, "/tmp/");
7070
len -= 5;
71-
} else
72-
len -= snprintf(pch, len, "%s/", env);
71+
pch += 5;
72+
} else {
73+
size_t n = snprintf(pch, len, "%s/", env);
74+
75+
len -= n;
76+
pch += n;
77+
}
7378

7479
safe_strncpy(pch, template, len);
7580

0 commit comments

Comments
 (0)