diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-04-10 19:37:44 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-04-10 19:37:44 +0800 |
commit | e198264c33367686003b30ae2399df6f286978bf (patch) | |
tree | 3a65517317fdfc01421f15361e8247114c8f1291 /common/sys | |
parent | 5d63b4b314f65bc3930406dece3a92810ea84511 (diff) | |
download | pttbbs-e198264c33367686003b30ae2399df6f286978bf.tar pttbbs-e198264c33367686003b30ae2399df6f286978bf.tar.gz pttbbs-e198264c33367686003b30ae2399df6f286978bf.tar.bz2 pttbbs-e198264c33367686003b30ae2399df6f286978bf.tar.lz pttbbs-e198264c33367686003b30ae2399df6f286978bf.tar.xz pttbbs-e198264c33367686003b30ae2399df6f286978bf.tar.zst pttbbs-e198264c33367686003b30ae2399df6f286978bf.zip |
- net: should not change constant string.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4126 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
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)); |