From 4e8a2c25129260c61df345f15715d75c715cb92c Mon Sep 17 00:00:00 2001 From: kcwu Date: Sat, 8 Apr 2006 14:58:06 +0000 Subject: 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 --- mbbsd/admin.c | 8 ++++++ mbbsd/bbs.c | 52 +++++++++++++++++++++++++++++++++++-- mbbsd/board.c | 77 ++++++++++++++++++++++++++++++++++++++++++++----------- mbbsd/brc.c | 1 + mbbsd/cache.c | 11 ++++++++ mbbsd/fav.c | 4 +++ mbbsd/friend.c | 2 ++ mbbsd/io.c | 7 +++++ mbbsd/mail.c | 1 + mbbsd/menu.c | 1 + mbbsd/stuff.c | 10 ++++++++ mbbsd/vote.c | 4 +++ mbbsd/voteboard.c | 1 + 13 files changed, 162 insertions(+), 17 deletions(-) (limited to 'mbbsd') diff --git a/mbbsd/admin.c b/mbbsd/admin.c index d4336052..c75c8ef0 100644 --- a/mbbsd/admin.c +++ b/mbbsd/admin.c @@ -339,6 +339,7 @@ setup_man(const boardheader_t * board, const boardheader_t * oldboard) void delete_symbolic_link(boardheader_t *bh, int bid) { + assert(0<=bid-1 && bid-1 0) { + assert(0<=bid-1 && bid-1perm_reload != last_chk_time) @@ -234,6 +236,7 @@ CheckPostPerm(void) if(!valid_index) { last_board_index = getbnum(currboard); + assert(0<=last_board_index-1 && last_board_index-1perm_reload; @@ -257,6 +260,7 @@ readtitle(void) boardheader_t *bp; char *brd_title; + assert(0<=currbid-1 && currbid-1bvote != 2 && bp->bvote) brd_title = "本看板進行投票中"; @@ -276,6 +280,7 @@ readtitle(void) #endif { char buf[32]; + assert(0<=currbid-1 && currbid-1bcache[currbid - 1].nuser); outslr("", 44, buf, -1); @@ -441,6 +446,7 @@ do_select(void) CompleteBoard(MSG_SELECT_BOARD, bname); if (bname[0] == '\0' || !(i = getbnum(bname))) return FULLUPDATE; + assert(0<=i-1 && i-1lastposttime[bid - 1] = now; touchbpostnum(bid, 1); } @@ -675,6 +682,7 @@ do_general(int isbid) int islocal, posttype=-1; ifuseanony = 0; + assert(0<=currbid-1 && currbid-1brdattr & BRD_VOTEBOARD) return do_voteboard(0); @@ -953,6 +962,7 @@ do_post_openbid(void) char ans[4]; boardheader_t *bp; + assert(0<=currbid-1 && currbid-1brdattr & BRD_VOTEBOARD)) { @@ -972,6 +982,7 @@ do_generalboardreply(/*const*/ fileheader_t * fhdr) { char genbuf[3]; + assert(0<=currbid-1 && currbid-1 (now - (time4_t)bcache[currbid - 1].post_limit_regtime * 2592000) || cuser.numlogins < ((unsigned int)(bcache[currbid - 1].post_limit_logins) * 10) || @@ -1046,6 +1057,7 @@ b_posttype(int ent, const fileheader_t * fhdr, const char *direct) if(!(currmode & MODE_BOARD)) return DONOTHING; + assert(0<=currbid-1 && currbid-1posttype_f = posttype_f; strlcpy(bp->posttype, posttype, sizeof(bp->posttype)); /* 這邊應該要防race condition */ + assert(0<=currbid-1 && currbid-1brdname, fhdr->filename); if (bp->brdattr & BRD_VOTEBOARD || (fhdr->filemode & FILE_VOTE)) @@ -1128,6 +1142,7 @@ edit_post(int ent, fileheader_t * fhdr, const char *direct) struct stat oldstat, newstat; int isSysop = 0, recordTouched = 0; + assert(0<=currbid-1 && currbid-1brdname, "Security") == 0) return DONOTHING; @@ -1292,6 +1307,7 @@ cross_post(int ent, fileheader_t * fhdr, const char *direct) move(2, 0); clrtoeol(); move(1, 0); + assert(0<=currbid-1 && currbid-1brdattr & BRD_VOTEBOARD) ) return FULLUPDATE; @@ -1309,6 +1325,7 @@ cross_post(int ent, fileheader_t * fhdr, const char *direct) /* 借用變數 */ ent = str_checksum(fhdr->title); author = getbnum(xboard); + assert(0<=author-1 && author-1brdattr & BRD_HIDE) && (bp->brdattr & BRD_POSTMASK)) { /* mosaic it */ @@ -1446,8 +1465,12 @@ cross_post(int ent, fileheader_t * fhdr, const char *direct) do_add_recommend(direct, fhdr, ent, buf, 2); } else #endif + { + int bid = getbnum(xboard); + assert(0<=bid-1 && bid-1 2550); bp->post_limit_posts = (unsigned char)(temp / 10); + assert(0<=currbid-1 && currbid-1brdname); vmsg("修改完成!"); @@ -1587,6 +1612,7 @@ do_limitedit(int ent, fileheader_t * fhdr, const char *direct) temp = atoi(genbuf); } while (temp < 0 || temp > 2550); bp->vote_limit_posts = (unsigned char)(temp / 10); + assert(0<=currbid-1 && currbid-1brdname); vmsg("修改完成!"); @@ -1650,6 +1676,7 @@ stop_gamble(void) { boardheader_t *bp = getbcache(currbid); char fn_ticket[128], fn_ticket_end[128]; + assert(0<=currbid-1 && currbid-1endgamble || bp->endgamble > now) return 0; @@ -1659,6 +1686,7 @@ stop_gamble(void) rename(fn_ticket, fn_ticket_end); if (bp->endgamble) { bp->endgamble = 0; + assert(0<=currbid-1 && currbid-1brdattr & BRD_BAD ) @@ -1705,6 +1735,7 @@ hold_gamble(void) rename(fn_ticket, fn_ticket_end); if (bp->endgamble) { bp->endgamble = 0; + assert(0<=currbid-1 && currbid-1endgamble = gettime(4, now, "封盤於"); + assert(0<=currbid-1 && currbid-1brdattr & BRD_NORECOMMEND || ((fhdr->filemode & FILE_MARKED) && (fhdr->filemode & FILE_SOLVED))) { @@ -2298,6 +2331,7 @@ recommend(int ent, fileheader_t * fhdr, const char *direct) inc_goodpost(fhdr->owner, 1); #endif lastrecommend = now; + assert(0<=currbid-1 && currbid-1filename, sizeof(lastrecommend_fname)); return FULLUPDATE; @@ -2344,6 +2378,7 @@ del_range(int ent, const fileheader_t *fhdr, const char *direct) /* 有三種情況會進這裡, 信件, 看板, 精華區 */ if( !(direct[0] == 'h') ){ /* 信件不用 check */ + assert(0<=currbid-1 && currbid-1brdname, "Security") == 0) return DONOTHING; @@ -2401,6 +2436,7 @@ del_post(int ent, fileheader_t * fhdr, char *direct) int not_owned, tusernum; boardheader_t *bp; + assert(0<=currbid-1 && currbid-1brdname, fn_notes); aborted = vedit(buf, NA, NULL); if (aborted == -1) { @@ -2660,6 +2697,7 @@ b_note_edit_bname(int bid) "有效日期至"); else fh->bupdate = 0; + assert(0<=bid-1 && bid-1title + 7, genbuf, sizeof(bp->title) - 7); + assert(0<=currbid-1 && currbid-1filemode ^= FILE_BOTTOM; num = delete_record(direct, sizeof(fileheader_t), ent); } + assert(0<=currbid-1 && currbid-1brdattr & BRD_HIDE)) { getdata(1, 0, "好文值得出版到全站文摘?(N/y)", genbuf2, 3, LCECHO); if(genbuf2[0] == 'y') @@ -3112,6 +3156,7 @@ b_config(void) } if(touched) { + assert(0<=currbid-1 && currbid-1brdname); pressanykey(); @@ -3179,6 +3225,7 @@ change_counting(void) bp->brdattr |= BRD_BMCOUNT; outs("快灌水衝十大第一吧。\n"); } + assert(0<=currbid-1 && currbid-1brdattr |= BRD_COOLDOWN; outs("開始冷靜。\n"); } + assert(0<=currbid-1 && currbid-1 0) static int class_bid = 0; +static int nbrdsize = 0; static boardstat_t *nbrd = NULL; static char choose_board_depth = 0; static short brdnum; @@ -168,7 +169,10 @@ load_uidofgid(const int gid, const int type) { boardheader_t *bptr, *currbptr, *parent; int bid, n, childcount = 0; + assert(0<=type && type<2); + assert(0<= gid-1 && gid-1bsorted[type][n]+1; if( bid<=0 || !(bptr = getbcache(bid)) @@ -197,6 +201,8 @@ addnewbrdstat(int n, int state) { boardstat_t *ptr; + assert(0<=n && ntotal = &(SHM->total[n]); @@ -248,6 +254,7 @@ load_boards(char *key) brdnum = 0; if (nbrd) { free(nbrd); + nbrdsize = 0; nbrd = NULL; } if (!IN_CLASS()) { @@ -255,9 +262,11 @@ load_boards(char *key) fav_t *fav = get_current_fav(); int nfav = get_data_number(fav); if( nfav == 0 ){ + nbrdsize = 1; nbrd = (boardstat_t *)malloc(sizeof(boardstat_t) * 1); goto EMPTYFAV; } + nbrdsize = nfav; nbrd = (boardstat_t *)malloc(sizeof(boardstat_t) * nfav); for( i = 0 ; i < fav->DataTail; ++i ){ int state; @@ -287,6 +296,7 @@ load_boards(char *key) continue; }else{ boardheader_t *bptr = getbcache(fav_getid(&fav->favh[i])); + assert(0<=fav_getid(&fav->favh[i])-1 && fav_getid(&fav->favh[i])-1title, key)) state = NBRD_BOARD; else @@ -308,8 +318,10 @@ load_boards(char *key) } #if HOTBOARDCACHE else if(IN_HOTBOARD()){ - nbrd = (boardstat_t *)malloc(sizeof(boardstat_t) * SHM->nHOTs); - for( i = 0 ; i < SHM->nHOTs ; ++i ) { + nbrdsize = SHM->nHOTs; + assert(0HBcache[i] == -1) continue; addnewbrdstat(SHM->HBcache[i], HasBoardPerm(&bcache[SHM->HBcache[i]])); @@ -317,8 +329,10 @@ load_boards(char *key) } #endif else { // general case - nbrd = (boardstat_t *) malloc(sizeof(boardstat_t) * numboards); - for (i = 0; i < numboards; i++) { + nbrdsize = numboards; + assert(0bsorted[type][i]; boardheader_t *bptr = &bcache[n]; if (n < 0 || bptr == NULL) @@ -344,15 +358,18 @@ load_boards(char *key) int childcount; int bid; + assert(0<=class_bid-1 && class_bid-1firstchild[type] == 0 || bptr->childcount==0) load_uidofgid(class_bid, type); childcount = bptr->childcount; // Ptt: child count after load_uidofgid - nbrd = (boardstat_t *) malloc((childcount+2) * sizeof(boardstat_t)); + nbrdsize = childcount + 5; + nbrd = (boardstat_t *) malloc((childcount+5) * sizeof(boardstat_t)); // 預留兩個以免大量開板時掛調 for (bid = bptr->firstchild[type]; bid > 0 && - brdnum < childcount+2; bid = bptr->next[type]) { + brdnum < childcount+5; bid = bptr->next[type]) { + assert(0<=bid-1 && bid-1childcount = 0; + if(childcount < brdnum) { + //Ptt: dirty fix fix soon + fprintf(stderr, "childcount < brdnum, %d<%d, class_bid=%d\n",childcount,brdnum,class_bid); + getbcache(class_bid)->childcount = 0; + } } @@ -383,6 +404,7 @@ search_board(void) move(0, 0); clrtoeol(); CreateNameList(); + assert(brdnum<=nbrdsize); for (num = 0; num < brdnum; num++) if (!IS_LISTING_FAV() || (nbrd[num].myattr & NBRD_BOARD && HasBoardPerm(B_BH(&nbrd[num]))) ) @@ -538,6 +560,7 @@ show_brdlist(int head, int clsflag, int newflag) move(myrow, 0); clrtoeol(); if (head < brdnum) { + assert(0<=head && headmyattr & NBRD_LINE){ if( !newflag ) @@ -646,6 +669,7 @@ set_menu_BM(char *BM) static void replace_link_by_target(boardstat_t *board) { + assert(0<=board->bid-1 && board->bid-1bid = BRD_LINK_TARGET(getbcache(board->bid)); board->myattr &= ~NBRD_SYMBOLIC; } @@ -661,12 +685,14 @@ paste_taged_brds(int gid) for (tmp = 0; tmp < fav->DataTail; tmp++) { boardheader_t *bh; bid = fav_getid(&fav->favh[tmp]); + assert(0<=bid-1 && bid-1favh[tmp], FAVH_ADM_TAG)) continue; set_attr(&fav->favh[tmp], FAVH_ADM_TAG, FALSE); if (bh->gid != gid) { bh->gid = gid; + assert(0<=bid-1 && bid-1myattr & NBRD_UNREAD) @@ -803,10 +830,12 @@ choose_board(int newflag) case '*': { int i = 0; + assert(brdnum<=nbrdsize); for (i = 0; i < brdnum; i++) { ptr = &nbrd[i]; if (IS_LISTING_FAV()){ + assert(nbrdsize>0); if(get_fav_type(&nbrd[0]) != 0) fav_tag(ptr->bid, get_fav_type(ptr), 2); } @@ -816,8 +845,10 @@ choose_board(int newflag) } break; case 't': + assert(0<=num && num0); if(get_fav_type(&nbrd[0]) != 0) fav_tag(ptr->bid, get_fav_type(ptr), 2); } @@ -895,6 +926,7 @@ choose_board(int newflag) case 'D': if (HasUserPerm(PERM_SYSOP) || (HasUserPerm(PERM_SYSSUPERSUBOP) && GROUPOP())) { + assert(0<=num && nummyattr & NBRD_SYMBOLIC) { if (getans("確定刪除連結?[N/y]") == 'y') @@ -941,6 +973,7 @@ choose_board(int newflag) break; } /* done move if it's the first item. */ + assert(nbrdsize>0); if (get_fav_type(&nbrd[0]) != 0) move_in_current_folder(brdnum, num); brdnum = -1; @@ -958,6 +991,7 @@ choose_board(int newflag) case 'z': case 'm': if (HasUserPerm(PERM_LOGINOK)) { + assert(0<=num && nummyattr & NBRD_FAV) { @@ -1005,6 +1039,7 @@ choose_board(int newflag) } fav_set_folder_title(ft, "新的目錄"); /* don't move if it's the first item */ + assert(nbrdsize>0); if (get_fav_type(&nbrd[0]) != 0) move_in_current_folder(brdnum, num); brdnum = -1; @@ -1012,6 +1047,7 @@ choose_board(int newflag) } break; case 'T': + assert(0<=num && num0); if (get_fav_type(&nbrd[0]) == 0) break; - else if (ptr->myattr & NBRD_LINE) + assert(0<=num && nummyattr & NBRD_LINE) break; - else if (ptr->myattr & NBRD_FOLDER){ + if (ptr->myattr & NBRD_FOLDER){ int t = num; num = 0; fav_folder_in(ptr->bid); @@ -1204,11 +1245,15 @@ choose_board(int newflag) head = 9999; break; } - } - else if (ptr->myattr & NBRD_SYMBOLIC) { - replace_link_by_target(ptr); + } else { + assert(0<=num && nummyattr & NBRD_SYMBOLIC) { + replace_link_by_target(ptr); + } } + assert(0<=ptr->bid-1 && ptr->bid-1brdattr & BRD_GROUPBOARD)) { /* 非sub class */ if (HasBoardPerm(B_BH(ptr))) { brc_initial_board(B_BH(ptr)->brdname); @@ -1250,6 +1295,7 @@ choose_board(int newflag) setutmpbid(ptr->bid); free(nbrd); nbrd = NULL; + nbrdsize = 0; if (IS_LISTING_FAV()) { LIST_BRD(); choose_board(0); @@ -1268,6 +1314,7 @@ choose_board(int newflag) } while (ch != 'q'); free(nbrd); nbrd = NULL; + nbrdsize = 0; --choose_board_depth; } diff --git a/mbbsd/brc.c b/mbbsd/brc.c index f30bef17..2f1639d0 100644 --- a/mbbsd/brc.c +++ b/mbbsd/brc.c @@ -371,6 +371,7 @@ brc_initial_board(const char *boardname) currbid = getbnum(boardname); if( currbid == 0 ) currbid = getbnum(DEFAULT_BOARD); + assert(0<=currbid-1 && currbid-1total[bid - 1] = 0; SHM->lastposttime[bid - 1] = 0; } @@ -644,6 +645,7 @@ reset_board(int bid) /* XXXbid: from 1 */ if (--bid < 0) return; + assert(0<=bid && bidBbusystate || COMMON_TIME - SHM->busystate_b[bid] < 10) { safe_sleep(1); } else { @@ -685,6 +687,7 @@ setbottomtotal(int bid) char fname[PATHLEN]; int n; + assert(0<=bid-1 && bid-1brdname[0]) return; setbfile(fname, bh->brdname, ".DIR.bottom"); n = get_num_records(fname, sizeof(fileheader_t)); @@ -707,11 +710,13 @@ setbtotal(int bid) char genbuf[256]; int num, fd; + assert(0<=bid-1 && bid-1brdname, ".DIR"); if ((fd = open(genbuf, O_RDWR)) < 0) return; /* .DIR掛了 */ fstat(fd, &st); num = st.st_size / sizeof(fileheader_t); + assert(0<=bid-1 && bid-1total[bid - 1] = num; if (num > 0) { @@ -728,6 +733,7 @@ void touchbpostnum(int bid, int delta) { int *total = &SHM->total[bid - 1]; + assert(0<=bid-1 && bid-1BM, sizeof(s)); for( i = 0 ; s[i] != 0 ; ++i ) if( !isalpha((int)s[i]) && !isdigit((int)s[i]) ) @@ -815,6 +823,7 @@ void buildBMcache(int bid) /* bid starts from 1 */ int is_BM_cache(int bid) /* bid starts from 1 */ { + assert(0<=bid-1 && bid-1uid == SHM->BMcache[bid][0] || @@ -1006,6 +1015,7 @@ hbflreload(int bid) char buf[128]; FILE *fp; + assert(0<=bid-1 && bid-1hbfl[bid-1][0] < login_start_time - HBFLexpire) hbflreload(bid); for (i = 1; SHM->hbfl[bid-1][i] != 0 && i <= MAX_FRIEND; ++i) { diff --git a/mbbsd/fav.c b/mbbsd/fav.c index bf1c7b7e..fa7d144c 100644 --- a/mbbsd/fav.c +++ b/mbbsd/fav.c @@ -207,6 +207,7 @@ char *get_item_title(fav_type_t *ft) { switch (get_item_type(ft)){ case FAVT_BOARD: + assert(0<=cast_board(ft)->bid-1 && cast_board(ft)->bid-1bid - 1].brdname; case FAVT_FOLDER: return cast_folder(ft)->title; @@ -220,6 +221,7 @@ static char *get_item_class(fav_type_t *ft) { switch (get_item_type(ft)){ case FAVT_BOARD: + assert(0<=cast_board(ft)->bid-1 && cast_board(ft)->bid-1bid - 1].title; case FAVT_FOLDER: return "目錄"; @@ -691,6 +693,7 @@ fav_type_t *getadmtag(short bid) int i; fav_t *fp = get_fav_root(); fav_type_t *ft; + assert(0<=bid-1 && bid-1DataTail; i++) { ft = &fp->favh[i]; if (get_item_type(ft) == FAVT_BOARD && cast_board(ft)->bid == bid && is_set_attr(ft, FAVH_ADM_TAG)) @@ -701,6 +704,7 @@ fav_type_t *getadmtag(short bid) fav_type_t *getboard(short bid) { + assert(0<=bid-1 && bid-1perm_reload = now; + assert(0<=currbid-1 && currbid-1brdname); } diff --git a/mbbsd/io.c b/mbbsd/io.c index b933616a..c1efde24 100644 --- a/mbbsd/io.c +++ b/mbbsd/io.c @@ -825,6 +825,7 @@ oldgetdata(int line, int col, const char *prompt, char *buf, int len, int echo) } while (1) { + assert(0<=clen); if(dirty_line) { move(line, col); clrtoeol(); @@ -844,6 +845,7 @@ oldgetdata(int line, int col, const char *prompt, char *buf, int len, int echo) if ((ch = igetch()) == '\r') break; + assert(0<=clen); switch (ch) { case KEY_DOWN: case Ctrl('N'): case KEY_UP: case Ctrl('P'): @@ -876,6 +878,7 @@ oldgetdata(int line, int col, const char *prompt, char *buf, int len, int echo) currchar --; #endif } + assert(0<=clen); break; case KEY_RIGHT: if (buf[currchar]) @@ -888,6 +891,7 @@ oldgetdata(int line, int col, const char *prompt, char *buf, int len, int echo) currchar++; #endif } + assert(0<=clen); break; case '\177': case Ctrl('H'): @@ -998,6 +1002,7 @@ oldgetdata(int line, int col, const char *prompt, char *buf, int len, int echo) } break; } /* end case */ + assert(0<=clen); } /* end while */ if (clen > 1) { @@ -1008,6 +1013,8 @@ oldgetdata(int line, int col, const char *prompt, char *buf, int len, int echo) // outc('\n'); move(y+1, 0); refresh(); + assert(0<=currchar && currchar<=clen); + assert(0<=clen && clen<=len); } if ((echo == LCECHO) && isupper((int)buf[0])) buf[0] = tolower(buf[0]); diff --git a/mbbsd/mail.c b/mbbsd/mail.c index 2b82fb3e..86c1124b 100644 --- a/mbbsd/mail.c +++ b/mbbsd/mail.c @@ -1263,6 +1263,7 @@ mail_cross_post(int ent, fileheader_t * fhdr, const char *direct) return FULLUPDATE; ent = getbnum(xboard); + assert(0<=ent-1 && ent-1 (now - (time4_t)bcache[ent - 1].post_limit_regtime * 2592000) || cuser.numlogins < ((unsigned int)(bcache[ent - 1].post_limit_logins) * 10) || diff --git a/mbbsd/menu.c b/mbbsd/menu.c index 99c2c8ba..fa111d4f 100644 --- a/mbbsd/menu.c +++ b/mbbsd/menu.c @@ -51,6 +51,7 @@ showtitle(const char *title, const char *mid) int bid = getbnum(currboard); if(bid > 0) { + assert(0<=bid-1 && bid-1brdattr & BRD_HIDE) && (getbcache(bid)->brdattr & BRD_POSTMASK)); strlcpy(lastboard, currboard, sizeof(lastboard)); diff --git a/mbbsd/stuff.c b/mbbsd/stuff.c index 37a8ebb1..b4b479f2 100644 --- a/mbbsd/stuff.c +++ b/mbbsd/stuff.c @@ -41,6 +41,7 @@ void sethomefile(char *buf, const char *userid, const char *fname) { assert(is_validuserid(userid)); + assert(fname[0]); snprintf(buf, PATHLEN, str_home_file, userid[0], userid, fname); } @@ -48,30 +49,35 @@ void setuserfile(char *buf, const char *fname) { assert(is_validuserid(cuser.userid)); + assert(fname[0]); snprintf(buf, PATHLEN, str_home_file, cuser.userid[0], cuser.userid, fname); } void setapath(char *buf, const char *boardname) { + //assert(boardname[0]); snprintf(buf, PATHLEN, "man/boards/%c/%s", boardname[0], boardname); } void setadir(char *buf, const char *path) { + //assert(path[0]); snprintf(buf, PATHLEN, "%s/%s", path, str_dotdir); } void setbpath(char *buf, const char *boardname) { + //assert(boardname[0]); snprintf(buf, PATHLEN, "boards/%c/%s", boardname[0], boardname); } void setbdir(char *buf, const char *boardname) { + //assert(boardname[0]); snprintf(buf, PATHLEN, str_board_file, boardname[0], boardname, (currmode & MODE_DIGEST ? fn_mandex : str_dotdir)); } @@ -79,12 +85,16 @@ setbdir(char *buf, const char *boardname) void setbfile(char *buf, const char *boardname, const char *fname) { + //assert(boardname[0]); + assert(fname[0]); snprintf(buf, PATHLEN, str_board_file, boardname[0], boardname, fname); } void setbnfile(char *buf, const char *boardname, const char *fname, int n) { + //assert(boardname[0]); + assert(fname[0]); snprintf(buf, PATHLEN, str_board_n_file, boardname[0], boardname, fname, n); } 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-1bvote != 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