From 638bfeca105f64a85f1e8696ee9144968e4c33c6 Mon Sep 17 00:00:00 2001 From: kcwu Date: Sat, 27 Aug 2005 12:31:57 +0000 Subject: fix off-by-one bug. git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3087 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/fav.c | 5 ++--- 1 file 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])){ -- cgit v1.2.3