[PATCH] git_mkstemp() fix
authorHolger Eitzenberger <holger@my-eitzenberger.de>
Mon, 8 Aug 2005 20:33:08 +0000 (22:33 +0200)
committerJunio C Hamano <junkio@cox.net>
Tue, 9 Aug 2005 05:51:44 +0000 (22:51 -0700)
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>
path.c

diff --git a/path.c b/path.c
index 7ef0d1b80d926d832816a587ddff721cb03130b3..b85f087f4390f1235a6b9e9545b3f6dd8457fdd5 100644 (file)
--- 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);