diff options
author | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2006-04-08 22:58:06 +0800 |
---|---|---|
committer | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2006-04-08 22:58:06 +0800 |
commit | 4e8a2c25129260c61df345f15715d75c715cb92c (patch) | |
tree | 9056598d7d2db1fe74cbe22fcabf047148c00e03 /mbbsd/vote.c | |
parent | 55e87717eb4ab1efdcba4d2622c1c98c71f871e3 (diff) | |
download | pttbbs-4e8a2c25129260c61df345f15715d75c715cb92c.tar pttbbs-4e8a2c25129260c61df345f15715d75c715cb92c.tar.gz pttbbs-4e8a2c25129260c61df345f15715d75c715cb92c.tar.bz2 pttbbs-4e8a2c25129260c61df345f15715d75c715cb92c.tar.lz pttbbs-4e8a2c25129260c61df345f15715d75c715cb92c.tar.xz pttbbs-4e8a2c25129260c61df345f15715d75c715cb92c.tar.zst pttbbs-4e8a2c25129260c61df345f15715d75c715cb92c.zip |
add a lot of assertions to ensure bid is in correct range when access via bid.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3341 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/vote.c')
-rw-r--r-- | mbbsd/vote.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/mbbsd/vote.c b/mbbsd/vote.c index e12d72f0..62fa1c3b 100644 --- a/mbbsd/vote.c +++ b/mbbsd/vote.c @@ -534,6 +534,7 @@ vote_view(vote_buffer_t *vbuf, const char *bname, int vote_index) fclose(fp); free(counts); pos = getbnum(bname); + assert(0<=pos-1 && pos-1<MAX_BOARD); fhp = bcache + pos - 1; move(t_lines - 3, 0); prints("◆ 目前總票數 = %d 票", total); @@ -634,6 +635,7 @@ vote_maintain(const char *bname) if ((pos = getbnum(bname)) <= 0) return 0; + assert(0<=pos-1 && pos-1<MAX_BOARD); fhp = bcache + pos - 1; if (fhp->bvote != 0) { @@ -918,6 +920,7 @@ user_vote_one(vote_buffer_t *vbuf, const char *bname, int ind) if ((pos = getbnum(bname)) <= 0) return 0; + assert(0<=pos-1 && pos-1<MAX_BOARD); fhp = bcache + pos - 1; #if 0 // backward compatible setbfile(buf, bname, STR_new_control); @@ -1096,6 +1099,7 @@ user_vote(const char *bname) if ((pos = getbnum(bname)) <= 0) return 0; + assert(0<=pos-1 && pos-1<MAX_BOARD); fhp = bcache + pos - 1; move(0, 0); |