diff options
author | James McCoy <jamessan@jamessan.com> | 2017-05-27 20:27:33 -0400 |
---|---|---|
committer | James McCoy <jamessan@jamessan.com> | 2017-05-27 20:27:33 -0400 |
commit | 3f85c2e43abb3e5f88745849ea35ec0c57b53784 (patch) | |
tree | 5f237027b965643b87f873653a06c28d17efb519 | |
parent | 156e6f274f7ecc65e07176a39eee9600d0beaaf1 (diff) | |
download | rneovim-3f85c2e43abb3e5f88745849ea35ec0c57b53784.tar.gz rneovim-3f85c2e43abb3e5f88745849ea35ec0c57b53784.tar.bz2 rneovim-3f85c2e43abb3e5f88745849ea35ec0c57b53784.zip |
Server: Call uv_getaddrinfo with NULL service when no port
When using serverstart("ip.ad.d.r:") to listen on a random port, we need
to abide by getaddrinfo()'s API and pass in a NULL service, rather than
an empty string.
When given an empty string, getaddrinfo() is free to search for a
service by the given name (since the string isn't a number) which will
fail. At least FreeBSD does perform this lookup.
-rw-r--r-- | src/nvim/event/socket.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/nvim/event/socket.c b/src/nvim/event/socket.c index 82686641c0..997dd29a7f 100644 --- a/src/nvim/event/socket.c +++ b/src/nvim/event/socket.c @@ -45,6 +45,12 @@ int socket_watcher_init(Loop *loop, SocketWatcher *watcher, return UV_EINVAL; } + if (*port == NUL) { + // When no port is given, (uv_)getaddrinfo expects NULL otherwise the + // implementation may attempt to lookup the service by name (and fail) + port = NULL; + } + uv_getaddrinfo_t request; int retval = uv_getaddrinfo(&loop->uv, &request, NULL, addr, port, |