summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHolger Eitzenberger <holger@my-eitzenberger.de>2005-08-08 20:33:08 (GMT)
committerJunio C Hamano <junkio@cox.net>2005-08-09 05:51:44 (GMT)
commit35c3c6298308563a3dd4a5c4bb0870748833643f (patch)
treee5672b98ff21287058c5809c87420a272a4da714
parentaffa40d2f8c5e72af5896cf395ef77d4162908cd (diff)
downloadgit-35c3c6298308563a3dd4a5c4bb0870748833643f.zip
git-35c3c6298308563a3dd4a5c4bb0870748833643f.tar.gz
git-35c3c6298308563a3dd4a5c4bb0870748833643f.tar.bz2
[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 <junkio@cox.net>
-rw-r--r--path.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/path.c b/path.c
index 7ef0d1b..b85f087 100644
--- a/path.c
+++ b/path.c
@@ -68,8 +68,13 @@ int git_mkstemp(char *path, size_t len, const char *template)
if ((env = getenv("TMPDIR")) == NULL) {
strcpy(pch, "/tmp/");
len -= 5;
- } else
- len -= snprintf(pch, len, "%s/", env);
+ pch += 5;
+ } else {
+ size_t n = snprintf(pch, len, "%s/", env);
+
+ len -= n;
+ pch += n;
+ }
safe_strncpy(pch, template, len);