* [PATCH 1/3] daemon: handle gethostbyname() error
@ 2014-10-01 10:16 René Scharfe
2014-10-01 10:18 ` [PATCH 2/3] daemon: fix error message after bind() René Scharfe
2014-10-01 20:35 ` [PATCH 1/3] daemon: handle gethostbyname() error Junio C Hamano
0 siblings, 2 replies; 4+ messages in thread
From: René Scharfe @ 2014-10-01 10:16 UTC (permalink / raw)
To: Git Mailing List; +Cc: Junio C Hamano
If the user-supplied hostname can't be found then we should not use it.
We already avoid doing that in the non-NO_IPV6 case by checking if the
return value of getaddrinfo() is zero (success). Do the same in the
NO_IPV6 case and make sure the return value of gethostbyname() isn't
NULL before dereferencing this pointer.
Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
Most lines are just re-indented, not actually changed.
daemon.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/daemon.c b/daemon.c
index 4dcfff9..a6f467e 100644
--- a/daemon.c
+++ b/daemon.c
@@ -553,20 +553,21 @@ static void parse_host_arg(char *extra_args, int buflen)
static char addrbuf[HOST_NAME_MAX + 1];
hent = gethostbyname(hostname);
+ if (hent) {
+ ap = hent->h_addr_list;
+ memset(&sa, 0, sizeof sa);
+ sa.sin_family = hent->h_addrtype;
+ sa.sin_port = htons(0);
+ memcpy(&sa.sin_addr, *ap, hent->h_length);
+
+ inet_ntop(hent->h_addrtype, &sa.sin_addr,
+ addrbuf, sizeof(addrbuf));
- ap = hent->h_addr_list;
- memset(&sa, 0, sizeof sa);
- sa.sin_family = hent->h_addrtype;
- sa.sin_port = htons(0);
- memcpy(&sa.sin_addr, *ap, hent->h_length);
-
- inet_ntop(hent->h_addrtype, &sa.sin_addr,
- addrbuf, sizeof(addrbuf));
-
- free(canon_hostname);
- canon_hostname = xstrdup(hent->h_name);
- free(ip_address);
- ip_address = xstrdup(addrbuf);
+ free(canon_hostname);
+ canon_hostname = xstrdup(hent->h_name);
+ free(ip_address);
+ ip_address = xstrdup(addrbuf);
+ }
#endif
}
}
--
2.1.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] daemon: fix error message after bind()
2014-10-01 10:16 [PATCH 1/3] daemon: handle gethostbyname() error René Scharfe
@ 2014-10-01 10:18 ` René Scharfe
2014-10-01 10:21 ` [PATCH 3/3] daemon: remove write-only variable maxfd René Scharfe
2014-10-01 20:35 ` [PATCH 1/3] daemon: handle gethostbyname() error Junio C Hamano
1 sibling, 1 reply; 4+ messages in thread
From: René Scharfe @ 2014-10-01 10:18 UTC (permalink / raw)
To: Git Mailing List; +Cc: Junio C Hamano
Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
daemon.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/daemon.c b/daemon.c
index a6f467e..090f6a4 100644
--- a/daemon.c
+++ b/daemon.c
@@ -924,7 +924,7 @@ static int setup_named_sock(char *listen_addr, int listen_port, struct socketlis
}
if ( bind(sockfd, (struct sockaddr *)&sin, sizeof sin) < 0 ) {
- logerror("Could not listen to %s: %s",
+ logerror("Could not bind to %s: %s",
ip2str(AF_INET, (struct sockaddr *)&sin, sizeof(sin)),
strerror(errno));
close(sockfd);
--
2.1.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] daemon: remove write-only variable maxfd
2014-10-01 10:18 ` [PATCH 2/3] daemon: fix error message after bind() René Scharfe
@ 2014-10-01 10:21 ` René Scharfe
0 siblings, 0 replies; 4+ messages in thread
From: René Scharfe @ 2014-10-01 10:21 UTC (permalink / raw)
To: Git Mailing List; +Cc: Junio C Hamano
It became unused when 6573faff (NO_IPV6 support for git daemon) replaced
select() with poll().
Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
daemon.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/daemon.c b/daemon.c
index 090f6a4..54a03bd 100644
--- a/daemon.c
+++ b/daemon.c
@@ -815,7 +815,6 @@ static const char *ip2str(int family, struct sockaddr *sin, socklen_t len)
static int setup_named_sock(char *listen_addr, int listen_port, struct socketlist *socklist)
{
int socknum = 0;
- int maxfd = -1;
char pbuf[NI_MAXSERV];
struct addrinfo hints, *ai0, *ai;
int gai;
@@ -883,9 +882,6 @@ static int setup_named_sock(char *listen_addr, int listen_port, struct socketlis
ALLOC_GROW(socklist->list, socklist->nr + 1, socklist->alloc);
socklist->list[socklist->nr++] = sockfd;
socknum++;
-
- if (maxfd < sockfd)
- maxfd = sockfd;
}
freeaddrinfo(ai0);
--
2.1.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/3] daemon: handle gethostbyname() error
2014-10-01 10:16 [PATCH 1/3] daemon: handle gethostbyname() error René Scharfe
2014-10-01 10:18 ` [PATCH 2/3] daemon: fix error message after bind() René Scharfe
@ 2014-10-01 20:35 ` Junio C Hamano
1 sibling, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2014-10-01 20:35 UTC (permalink / raw)
To: René Scharfe; +Cc: Git Mailing List
All three look trivially correct. Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-10-01 20:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-01 10:16 [PATCH 1/3] daemon: handle gethostbyname() error René Scharfe
2014-10-01 10:18 ` [PATCH 2/3] daemon: fix error message after bind() René Scharfe
2014-10-01 10:21 ` [PATCH 3/3] daemon: remove write-only variable maxfd René Scharfe
2014-10-01 20:35 ` [PATCH 1/3] daemon: handle gethostbyname() error Junio C Hamano
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).