Fix some termination issues.

This commit is contained in:
Oliver Jowett 2016-02-16 13:05:03 +00:00
parent a2eb71d49a
commit eb16ac2028

View file

@ -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",