git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Workaround for ai_canonname sometimes coming back as null
@ 2009-04-29 21:48 Augie Fackler
  2009-04-29 21:55 ` Alex Riesen
  0 siblings, 1 reply; 11+ messages in thread
From: Augie Fackler @ 2009-04-29 21:48 UTC (permalink / raw)
  To: git

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

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2009-04-30 16:57 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-29 21:48 [PATCH] Workaround for ai_canonname sometimes coming back as null Augie Fackler
2009-04-29 21:55 ` Alex Riesen
2009-04-29 21:56   ` Augie Fackler
2009-04-29 22:01     ` Alex Riesen
2009-04-29 22:04     ` Alex Riesen
2009-04-29 23:04       ` [PATCH] Don't crash if ai_canonname comes " Augie Fackler
2009-04-29 23:21         ` Junio C Hamano
2009-04-29 23:32           ` Augie Fackler
2009-04-30 14:13             ` Jon Loeliger
2009-04-30 16:57               ` Junio C Hamano
2009-04-29 21:56   ` [PATCH] Workaround for ai_canonname sometimes coming " Alex Riesen

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).