From: Augie Fackler Date: Wed, 29 Apr 2009 21:48:57 GMT Subject: [PATCH] Workaround for ai_canonname sometimes coming back as null Message-ID: <9C355DCC-0240-4B9E-83CA-083B51C2E34C@gmail.com> Fix a weird bug where git-daemon was segfaulting when started by sh(1) because ai_canonname was null. --- I'm not really sure why being started by sh has any measurable impact. git-daemon works fine if I start it manually from an interactive prompt. Easy reproduction script (the git clone command will fail reliably for me without this patch): #!/bin/sh mkdir temp cd temp mkdir narf cd narf git init echo a > a git add a git commit -am 'hi' cd .. git daemon --base-path="$(pwd)"\ --listen=127.0.0.1\ --export-all\ --pid-file=gitdaemon.pid \ --detach --reuseaddr git clone git://127.0.0.1/narf bla kill `cat gitdaemon.pid` daemon.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/daemon.c b/daemon.c index 13401f1..b1fede0 100644 --- a/daemon.c +++ b/daemon.c @@ -459,7 +459,10 @@ 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); + if (ai->ai_canonname) + canon_hostname = xstrdup(ai->ai_canonname); + else + canon_hostname = "unknown"; free(ip_address); ip_address = xstrdup(addrbuf); break; -- 1.6.3.rc3.12.gb7937