Code

link_temp_to_file: don't leave the path truncated on adjust_shared_perm failure
[git.git] / sha1_file.c
index 716aef33e3a28039a8659d77d6797dc183730643..5fcad2893fec7739262b06e2883ee3c261768099 100644 (file)
@@ -908,7 +908,7 @@ static int packed_delta_info(struct packed_git *p,
 
        if (sizep) {
                const unsigned char *data;
-               unsigned char delta_head[64];
+               unsigned char delta_head[20];
                unsigned long result_size;
                z_stream stream;
                int st;
@@ -1383,8 +1383,10 @@ static int link_temp_to_file(const char *tmpfile, const char *filename)
        if (dir) {
                *dir = 0;
                mkdir(filename, 0777);
-               if (adjust_shared_perm(filename))
+               if (adjust_shared_perm(filename)) {
+                       *dir = '/';
                        return -2;
+               }
                *dir = '/';
                if (!link(tmpfile, filename))
                        return 0;