git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Torsten Bögershausen" <tboegi@web.de>
To: Karsten Blees <karsten.blees@gmail.com>,
	Jeff King <peff@peff.net>, Junio C Hamano <gitster@pobox.com>
Cc: Jorge <griffin@gmx.es>, git@vger.kernel.org
Subject: Re: [PATCH] config.c: fix writing config files on Windows network shares
Date: Tue, 30 Jun 2015 16:46:20 +0200	[thread overview]
Message-ID: <5592ABBC.60904@web.de> (raw)
In-Reply-To: <5592A8E5.2090601@gmail.com>

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@dcon.de>
> ---
> 
> 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)

  reply	other threads:[~2015-06-30 14:46 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-27 13:29 Bug: .gitconfig folder Jorge
2015-05-27 20:30 ` Junio C Hamano
2015-05-27 22:18   ` Jeff King
2015-05-27 22:24     ` Stefan Beller
2015-05-28  6:13       ` Jeff King
2015-05-27 22:38     ` Junio C Hamano
2015-05-28  7:51       ` Jeff King
2015-05-28  7:54         ` [PATCH 1/4] read-cache.c: drop PROT_WRITE from mmap of index Jeff King
2015-05-28  7:54         ` [PATCH 2/4] config.c: fix mmap leak when writing config Jeff King
2015-06-30 14:34           ` [PATCH] config.c: fix writing config files on Windows network shares Karsten Blees
2015-06-30 14:46             ` Torsten Bögershausen [this message]
2015-06-30 16:01               ` Jeff King
2015-06-30 14:52             ` Johannes Schindelin
2015-06-30 16:00             ` Jeff King
2015-05-28  7:56         ` [PATCH 3/4] config.c: avoid xmmap error messages Jeff King
2015-05-28  8:03         ` [PATCH 4/4] config.c: rewrite ENODEV into EISDIR when mmap fails Jeff King
2015-05-28 17:11           ` Junio C Hamano
2015-05-28 20:44             ` Jeff King
2015-05-28 21:11               ` Junio C Hamano
2015-05-28 17:06         ` Bug: .gitconfig folder Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5592ABBC.60904@web.de \
    --to=tboegi@web.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=griffin@gmx.es \
    --cc=karsten.blees@gmail.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).