diff options
Diffstat (limited to 'common/sys')
-rw-r--r-- | common/sys/net.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/common/sys/net.c b/common/sys/net.c index df880f9b..df33392e 100644 --- a/common/sys/net.c +++ b/common/sys/net.c @@ -65,9 +65,11 @@ int tobind(const char * addr) } strlcpy(buf, addr, sizeof(buf)); - if ( (port = strchr(addr, ':')) != NULL) + if ( (port = strchr(buf, ':')) != NULL) *port++ = '\0'; + assert(port && atoi(port) != 0); + setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (char *)&val, sizeof(val)); servaddr.sin_family = AF_INET; @@ -125,9 +127,11 @@ int toconnect(const char *addr) } strlcpy(buf, addr, sizeof(buf)); - if ( (port = strchr(addr, ':')) != NULL) + if ( (port = strchr(buf, ':')) != NULL) *port++ = '\0'; + assert(port && atoi(port) != 0); + serv_name.sin_family = AF_INET; serv_name.sin_addr.s_addr = inet_addr(buf); serv_name.sin_port = htons(atoi(port)); |