summaryrefslogtreecommitdiffstats
path: root/mbbsd
diff options
context:
space:
mode:
authorkcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-08-27 20:31:57 +0800
committerkcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-08-27 20:31:57 +0800
commit638bfeca105f64a85f1e8696ee9144968e4c33c6 (patch)
treec957af8ddbaf7e9fe776ccac87ec361785932465 /mbbsd
parentbbc76a20e8c3d7603b610da78fd4641600948074 (diff)
downloadpttbbs-638bfeca105f64a85f1e8696ee9144968e4c33c6.tar
pttbbs-638bfeca105f64a85f1e8696ee9144968e4c33c6.tar.gz
pttbbs-638bfeca105f64a85f1e8696ee9144968e4c33c6.tar.bz2
pttbbs-638bfeca105f64a85f1e8696ee9144968e4c33c6.tar.lz
pttbbs-638bfeca105f64a85f1e8696ee9144968e4c33c6.tar.xz
pttbbs-638bfeca105f64a85f1e8696ee9144968e4c33c6.tar.zst
pttbbs-638bfeca105f64a85f1e8696ee9144968e4c33c6.zip
fix off-by-one bug.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3087 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r--mbbsd/fav.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/mbbsd/fav.c b/mbbsd/fav.c
index e7875a72..84951c14 100644
--- a/mbbsd/fav.c
+++ b/mbbsd/fav.c
@@ -1114,7 +1114,7 @@ int updatenewfav(int mode)
brd = (char *)malloc((brdnum + 1) * sizeof(char));
memset(brd, 0, (brdnum + 1) * sizeof(char));
- i = read(fd, brd, (brdnum + 1) * sizeof(char));
+ i = read(fd, brd, brdnum * sizeof(char));
if (i < 0) {
free(brd);
close(fd);
@@ -1122,10 +1122,9 @@ int updatenewfav(int mode)
return -1;
}
- /* if it's a new file, no BRD_END is in it. */
brd[i] = BRD_END;
- for(i = 0; i < brdnum + 1 && brd[i] != BRD_END; i++){
+ for(i = 0; i < brdnum && brd[i] != BRD_END; i++){
if(brd[i] == BRD_NEW){
/* check the permission if the board exsits */
if(bcache[i].brdname[0] && HasBoardPerm(&bcache[i])){