From: Augie Fackler Date: Wed, 29 Apr 2009 23:32:02 GMT Subject: Re: [PATCH] Don't crash if ai_canonname comes back as null Message-ID: In-Reply-To: <7v63gn59mw.fsf@gitster.siamese.dyndns.org> On Apr 29, 2009, at 6:21 PM, Junio C Hamano wrote: > Augie Fackler writes: > >> Fixes a weird bug where git-daemon was segfaulting >> when started by sh(1) because ai_canonname was null. >> --- >> Fixed based on feedback. > > Hmm. > > I've been waiting for feedback to a patch proposed earlier in the same > area, which is <49F5BA55.3060606@googlemail.com> ($gmane/117670). How > does this new one relate to it? I can't comment much on the correctness of the code - my patch was the minimal change to have it not crash. The other patch also works for me to prevent the crash, and looks like it might be a little more correct in terms of having a meaningful hostname. >> daemon.c | 2 +- >> 1 files changed, 1 insertions(+), 1 deletions(-) >> >> diff --git a/daemon.c b/daemon.c >> index 13401f1..ae21d92 100644 >> --- a/daemon.c >> +++ b/daemon.c >> @@ -459,7 +459,7 @@ static void parse_extra_args(char *extra_args, >> int >> buflen) >> inet_ntop(AF_INET, &sin_addr->sin_addr, >> addrbuf, sizeof(addrbuf)); >> free(canon_hostname); >> - canon_hostname = xstrdup(ai->ai_canonname); >> + canon_hostname = ai->ai_canonname ? >> xstrdup(ai->ai_canonname) : NULL; >> free(ip_address); >> ip_address = xstrdup(addrbuf); >> break; >> -- >> 1.6.2.GIT >