summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Swanson <swansontec@gmail.com>2014-09-24 12:01:14 -0700
committerCarlos Martín Nieto <cmn@dwim.me>2014-10-03 17:38:20 +0200
commitb59357797922c7482d973da3cbec307f132f77ba (patch)
treeb73adef1ae2631c1c9ab9a554d02d8e2a07a6972
parentba5cef034dbc9aa41a60f67e5748be0e1329eeb6 (diff)
downloadlibgit2-b59357797922c7482d973da3cbec307f132f77ba.tar.gz
Correctly handle getaddrinfo return result
The getaddrinfo function indicates failure with a non-zero return code, but this code is not necessarily negative. On platforms like Android where the code is positive, a failed call causes libgit2 to segfault.
-rw-r--r--src/netops.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/netops.c b/src/netops.c
index 8a60299c2..ea5d4ed2e 100644
--- a/src/netops.c
+++ b/src/netops.c
@@ -460,7 +460,7 @@ int gitno_connect(gitno_socket *s_out, const char *host, const char *port, int f
hints.ai_socktype = SOCK_STREAM;
hints.ai_family = AF_UNSPEC;
- if ((ret = p_getaddrinfo(host, port, &hints, &info)) < 0) {
+ if ((ret = p_getaddrinfo(host, port, &hints, &info)) != 0) {
giterr_set(GITERR_NET,
"Failed to resolve address for %s: %s", host, p_gai_strerror(ret));
return -1;