Fix some termination issues.
This commit is contained in:
parent
a2eb71d49a
commit
eb16ac2028
8
net_io.c
8
net_io.c
|
@ -191,17 +191,17 @@ void serviceListen(struct net_service *service, char *bind_addr, char *bind_port
|
||||||
end = strpbrk(p, ", ");
|
end = strpbrk(p, ", ");
|
||||||
if (!end) {
|
if (!end) {
|
||||||
strncpy(buf, p, sizeof(buf));
|
strncpy(buf, p, sizeof(buf));
|
||||||
|
buf[sizeof(buf)-1] = 0;
|
||||||
p = NULL;
|
p = NULL;
|
||||||
} else {
|
} else {
|
||||||
size_t len = end - p;
|
size_t len = end - p;
|
||||||
if (len > sizeof(buf))
|
if (len >= sizeof(buf))
|
||||||
len = sizeof(buf);
|
len = sizeof(buf) - 1;
|
||||||
memcpy(buf, p, len);
|
memcpy(buf, p, len);
|
||||||
|
buf[len] = 0;
|
||||||
p = end + 1;
|
p = end + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf[sizeof(buf)-1] = 0;
|
|
||||||
|
|
||||||
nfds = anetTcpServer(Modes.aneterr, buf, bind_addr, newfds, sizeof(newfds));
|
nfds = anetTcpServer(Modes.aneterr, buf, bind_addr, newfds, sizeof(newfds));
|
||||||
if (nfds == ANET_ERR) {
|
if (nfds == ANET_ERR) {
|
||||||
fprintf(stderr, "Error opening the listening port %s (%s): %s\n",
|
fprintf(stderr, "Error opening the listening port %s (%s): %s\n",
|
||||||
|
|
Loading…
Reference in a new issue