diff options
author | William Swanson <swansontec@gmail.com> | 2014-09-24 12:01:14 -0700 |
---|---|---|
committer | William Swanson <swansontec@gmail.com> | 2014-09-24 12:01:14 -0700 |
commit | d0cf1040c703c7131c7c70d9de6bc2dd78b25d57 (patch) | |
tree | 20ba34d8c440265b00695d2c87c226e0f6ac82e6 | |
parent | 2cd3cb8e03591e08c1cc1890ae5b82a498773f19 (diff) | |
download | libgit2-d0cf1040c703c7131c7c70d9de6bc2dd78b25d57.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.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/netops.c b/src/netops.c index 43b8c5311..adbae61c4 100644 --- a/src/netops.c +++ b/src/netops.c @@ -458,7 +458,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; |