aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndré Twupack <atwupack@mailbox.org>2014-06-28 16:52:45 +0200
committerNicolas Hillegeer <nicolas@hillegeer.com>2014-07-13 14:20:18 +0200
commitfa5615022c7c44c3d1482027b5c56849002361eb (patch)
tree2abd0eef1960a869917df401ba0082347442c425 /src
parent7c473dc0a25fa55a09f0288b09b47fab5caee589 (diff)
downloadrneovim-fa5615022c7c44c3d1482027b5c56849002361eb.tar.gz
rneovim-fa5615022c7c44c3d1482027b5c56849002361eb.tar.bz2
rneovim-fa5615022c7c44c3d1482027b5c56849002361eb.zip
os/server: Fix TCP connection
- remove unused errno - remove unused port_end - correct calculation of addr_len - use correct string length during IP copy
Diffstat (limited to 'src')
-rw-r--r--src/nvim/os/server.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/nvim/os/server.c b/src/nvim/os/server.c
index 375f3b5fa9..e5c21f3aca 100644
--- a/src/nvim/os/server.c
+++ b/src/nvim/os/server.c
@@ -116,21 +116,19 @@ void server_start(char *endpoint)
if (addr_len > sizeof(ip) - 1) {
// Maximum length of an IP address buffer is 15(eg: 255.255.255.255)
- addr_len = sizeof(ip);
+ addr_len = sizeof(ip) - 1;
}
// Extract the address part
- xstrlcpy(ip, addr, addr_len);
+ xstrlcpy(ip, addr, addr_len + 1);
int port = NEOVIM_DEFAULT_TCP_PORT;
if (*ip_end == ':') {
- char *port_end;
// Extract the port
- port = strtol(ip_end + 1, &port_end, 10);
- errno = 0;
+ port = strtol(ip_end + 1, NULL, 10);
- if (errno != 0 || port == 0 || port > 0xffff) {
+ if (port == 0 || port > 0xffff) {
// Invalid port, treat as named pipe or unix socket
server_type = kServerTypePipe;
}