summaryrefslogtreecommitdiffstats
path: root/mbbsd
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-02-06 15:49:26 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-02-06 15:49:26 +0800
commit3e4693fec74ba2ac35a958a36877a431998bfe29 (patch)
tree85a6e84996963a0578c3bd0208a0b1afdca12a01 /mbbsd
parent6992814160ed9cb2a62cb6af943d1bf1a0c09f78 (diff)
downloadpttbbs-3e4693fec74ba2ac35a958a36877a431998bfe29.tar
pttbbs-3e4693fec74ba2ac35a958a36877a431998bfe29.tar.gz
pttbbs-3e4693fec74ba2ac35a958a36877a431998bfe29.tar.bz2
pttbbs-3e4693fec74ba2ac35a958a36877a431998bfe29.tar.lz
pttbbs-3e4693fec74ba2ac35a958a36877a431998bfe29.tar.xz
pttbbs-3e4693fec74ba2ac35a958a36877a431998bfe29.tar.zst
pttbbs-3e4693fec74ba2ac35a958a36877a431998bfe29.zip
fix friend[] overflowing when using utmpserver.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2472 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r--mbbsd/talk.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/mbbsd/talk.c b/mbbsd/talk.c
index f8799f4e..8765fe40 100644
--- a/mbbsd/talk.c
+++ b/mbbsd/talk.c
@@ -230,12 +230,18 @@ void login_friend_online(void)
towrite(sfd, currutmp->friend, sizeof(currutmp->friend)) > 0 &&
towrite(sfd, currutmp->reject, sizeof(currutmp->reject)) > 0 ){
ocfs_t fs;
- while( toread(sfd, &fs, sizeof(fs)) > 0 )
+ while( currutmp->friendtotal < MAX_FRIEND &&
+ toread(sfd, &fs, sizeof(fs)) > 0 )
if( SHM->uinfo[fs.index].uid == fs.uid ){
currutmp->friend_online[currutmp->friendtotal++]
= fs.friendstat;
SHM->uinfo[fs.index].friend_online[ SHM->uinfo[fs.index].friendtotal++ ] = fs.rfriendstat;
}
+
+ /* 要把剩下的收完, 要不然會卡死 utmpserver */
+ if( currutmp->friendtotal == MAX_FRIEND )
+ while( toread(sfd, &fs, sizeof(fs)) > 0 )
+ ;
close(sfd);
return;
}