Re: Problem pushing to a Novell share

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Rüdiger Kessel <ruediger.kessel@xxxxxxxxx> writes:

> A quick fix is to improve the create_tmpfile() function in sha1_file.c:
>
> static int create_tmpfile(char *buffer, size_t bufsiz, const char *filename)
> {
>     static struct stat sb;
>     int fd, dirlen = directory_size(filename);
>
>     if (dirlen + 20 > bufsiz) {
>         errno = ENAMETOOLONG;
>         return -1;
>     }
>
>     memcpy(buffer, filename, dirlen);
>     buffer[dirlen-1] = 0;
>     if (stat(buffer, &sb) != 0 && errno == ENOENT) {
>         if (mkdir(buffer, 0777) || adjust_shared_perm(buffer))
>             return -1;
>     }
>
>     memcpy(buffer, filename, dirlen);
>     strcpy(buffer + dirlen, "tmp_obj_XXXXXX");
>     fd = git_mkstemp_mode(buffer, 0444);
>     return fd;
> }
>
> The function will create one missing directory level if it does not
> exist prior to creating the tmp-file.

Please remove your modification above, and follow the code we have.  We
try git_mkstemp_mode() first, because it is more common than not having
the leading directory and we do not want to waste an extra stat() every
tie we come here.  Only when the first attempt fails by returning error
(i.e. fd < 0 and errno == ENOENT), we try mkdir() and then try again.

If you see "missing directory", it would be because on your system the
code somehow does not notice the failure from the first attempt.  Why?

The breakage you are seeing could come from either:

 - git_mkstemp_mode(), more specifically, the underlying mkstemp(), not
   returning negative when it fails for some reason; or

 - when the above fails, it fails to set errno to ENOENT.

and *that* is what needs to be fixed.

I think pessimizing create_tmpfile() like you did is not a fix; it is
sweeping the real problem under the rug.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]