On Tue, Sep 28, 2010 at 11:13 PM, Johannes Sixt <j6t@xxxxxxxx> wrote: > On Dienstag, 28. September 2010, Erik Faye-Lund wrote: >> On Tue, Sep 28, 2010 at 10:52 PM, Johannes Sixt <j6t@xxxxxxxx> wrote: >> >> mingw: do not crash on open(NULL, ...) >> > >> > This one is bogus, and as it stands, it must have my Ack removed. :) >> > Needs the same fix in mingw_fopen as mingw_freopen. (There remains an >> > unprotected dereference of filename.) >> >> I believe the version in for-junio already has this fix squashed in. >> The following hunk, taken from >> http://repo.or.cz/w/git/mingw/4msysgit.git/blobdiff/4e93566b07dcf47ecb6484d >>225418c04c1eedee6..b18500977d88b13803ecc60cf383538139ec09d8:/compat/mingw.c >> shows that it is... Or are you thinking of something else? >> >> @@ -346,7 +346,7 @@ FILE *mingw_fopen (const char *filename, const char >> if (hide_dotfiles == HIDE_DOTFILES_TRUE && >> basename((char*)filename)[0] == '.') > ^^^^^^^^ > This can crash, too. > Ah, indeed. Thanks for pointing that out! I'll send out a new version, with this squashed on top: diff --git a/compat/mingw.c b/compat/mingw.c index 2fbe381..2584e9f 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -343,11 +343,13 @@ FILE *mingw_fopen (const char *filename, const char *otype) { int hide = 0; FILE *file; - if (hide_dotfiles == HIDE_DOTFILES_TRUE && - basename((char*)filename)[0] == '.') - hide = access(filename, F_OK); - if (filename && !strcmp(filename, "/dev/null")) - filename = "nul"; + if (filename) { + if (hide_dotfiles == HIDE_DOTFILES_TRUE && + basename((char*)filename)[0] == '.') + hide = access(filename, F_OK); + if (!strcmp(filename, "/dev/null")) + filename = "nul"; + } file = fopen(filename, otype); if (file && hide && make_hidden(filename)) warning("Could not mark '%s' as hidden.", filename); @@ -359,11 +361,13 @@ FILE *mingw_freopen (const char *filename, const char *otype, FILE *stream) { int hide = 0; FILE *file; - if (hide_dotfiles == HIDE_DOTFILES_TRUE && - basename((char*)filename)[0] == '.') - hide = access(filename, F_OK); - if (filename && !strcmp(filename, "/dev/null")) - filename = "nul"; + if (filename) { + if (hide_dotfiles == HIDE_DOTFILES_TRUE && + basename((char*)filename)[0] == '.') + hide = access(filename, F_OK); + if (!strcmp(filename, "/dev/null")) + filename = "nul"; + } file = freopen(filename, otype, stream); if (file && hide && make_hidden(filename)) warning("Could not mark '%s' as hidden.", filename); -- 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