Commit a117fd101a758954b55adeefed9599ebc41d5bd8

Stefan Sperling 2020-03-18T16:13:46

make addrinfo error messages more obvious

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
diff --git a/lib/fetch.c b/lib/fetch.c
index 325ffec..5ba32f3 100644
--- a/lib/fetch.c
+++ b/lib/fetch.c
@@ -133,8 +133,12 @@ dial_git(int *fetchfd, const char *host, const char *port, const char *path,
 	hints.ai_family = AF_UNSPEC;
 	hints.ai_socktype = SOCK_STREAM;
 	eaicode = getaddrinfo(host, port, &hints, &servinfo);
-	if (eaicode)
-		return got_error_msg(GOT_ERR_ADDRINFO, gai_strerror(eaicode));
+	if (eaicode) {
+		char msg[512];
+		snprintf(msg, sizeof(msg), "%s: %s", host,
+		    gai_strerror(eaicode));
+		return got_error_msg(GOT_ERR_ADDRINFO, msg);
+	}
 
 	for (p = servinfo; p != NULL; p = p->ai_next) {
 		if ((fd = socket(p->ai_family, p->ai_socktype,