From eb16ac2028b54ae5c987e993e22529856e805053 Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Tue, 16 Feb 2016 13:05:03 +0000 Subject: [PATCH] Fix some termination issues. --- net_io.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net_io.c b/net_io.c index 0f378f4..bff640f 100644 --- a/net_io.c +++ b/net_io.c @@ -191,17 +191,17 @@ void serviceListen(struct net_service *service, char *bind_addr, char *bind_port end = strpbrk(p, ", "); if (!end) { strncpy(buf, p, sizeof(buf)); + buf[sizeof(buf)-1] = 0; p = NULL; } else { size_t len = end - p; - if (len > sizeof(buf)) - len = sizeof(buf); + if (len >= sizeof(buf)) + len = sizeof(buf) - 1; memcpy(buf, p, len); + buf[len] = 0; p = end + 1; } - buf[sizeof(buf)-1] = 0; - nfds = anetTcpServer(Modes.aneterr, buf, bind_addr, newfds, sizeof(newfds)); if (nfds == ANET_ERR) { fprintf(stderr, "Error opening the listening port %s (%s): %s\n",