summaryrefslogtreecommitdiffstats
path: root/common/sys
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2008-04-10 19:37:44 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2008-04-10 19:37:44 +0800
commite198264c33367686003b30ae2399df6f286978bf (patch)
tree3a65517317fdfc01421f15361e8247114c8f1291 /common/sys
parent5d63b4b314f65bc3930406dece3a92810ea84511 (diff)
downloadpttbbs-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.c8
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));