Re: [PATCH] config.c: fix writing config files on Windows network shares

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

 



On 2015-06-30 16.34, Karsten Blees wrote:
> Renaming to an existing file doesn't work on Windows network shares if the
> target file is open.
> 
> munmap() the old config file before commit_lock_file.
> 
> Signed-off-by: Karsten Blees <blees@xxxxxxx>
> ---
> 
> See https://github.com/git-for-windows/git/issues/226
> 
> Strangely, renaming to an open file works fine on local disks...
> 
>  config.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/config.c b/config.c
> index 07133ef..3a23c11 100644
> --- a/config.c
> +++ b/config.c
> @@ -2153,6 +2153,9 @@ int git_config_set_multivar_in_file(const char *config_filename,
>  					  contents_sz - copy_begin) <
>  			    contents_sz - copy_begin)
>  				goto write_err_out;
> +
> +		munmap(contents, contents_sz);
> +		contents = NULL;
>  	}
>  
>  	if (commit_lock_file(lock) < 0) {
> 

Nice catch.
Talking about network file system,
somebody volunteering to fix this issue ?

The value of fstat() is not checked here:
(indicated by a compiler warning, that contents_sz may be uninitalized.

 config.c:
 int git_config_set_multivar_in_file(
 //around line 2063 (the only call to fstat())
 		fstat(in_fd, &st);
 		contents_sz = xsize_t(st.st_size);


(sorry for hijacking your email thread)

--
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]