Thread (7 messages) flat view 7 messages, 2 authors, 2016-06-15
DORMANTno replies

[PATCH] Workaround for ai_canonname sometimes coming back as null

From: Augie Fackler <hidden>
Date: 2016-06-15 22:46:41
Subsystem: the rest · Maintainer: Linus Torvalds

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help