Skip to content

Commit

Permalink
Fix some termination issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
mutability committed Feb 16, 2016
1 parent a2eb71d commit eb16ac2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions net_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit eb16ac2

Please sign in to comment.