git-mailinfo: Fix getting the subject from the in-body [PATCH] line
[gitweb.git] / sha1_file.c
index 191f814e09ee6067edf7b0acc73a04751e73a6da..d1c406081e29eab9843a5268b611af1a3e014227 100644 (file)
@@ -116,6 +116,15 @@ int safe_create_leading_directories(char *path)
        return 0;
 }
 
+int safe_create_leading_directories_const(const char *path)
+{
+       /* path points to cache entries, so xstrdup before messing with it */
+       char *buf = xstrdup(path);
+       int result = safe_create_leading_directories(buf);
+       free(buf);
+       return result;
+}
+
 char *sha1_to_hex(const unsigned char *sha1)
 {
        static int bufno;
@@ -2118,6 +2127,7 @@ static int create_tmpfile(char *buffer, size_t bufsiz, const char *filename)
        fd = mkstemp(buffer);
        if (fd < 0 && dirlen) {
                /* Make sure the directory exists */
+               memcpy(buffer, filename, dirlen);
                buffer[dirlen-1] = 0;
                if (mkdir(buffer, 0777) || adjust_shared_perm(buffer))
                        return -1;