diff options
author | victor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-11-11 01:04:46 +0800 |
---|---|---|
committer | victor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-11-11 01:04:46 +0800 |
commit | 5d6d1b984e33bde119a5322c6bc76e5c0e48f043 (patch) | |
tree | f1e8ca64214d89921b76c5f005a2ec2e20f3514f | |
parent | d4655322c745b6a78706369c5b1926962d0c61c2 (diff) | |
download | pttbbs-5d6d1b984e33bde119a5322c6bc76e5c0e48f043.tar pttbbs-5d6d1b984e33bde119a5322c6bc76e5c0e48f043.tar.gz pttbbs-5d6d1b984e33bde119a5322c6bc76e5c0e48f043.tar.bz2 pttbbs-5d6d1b984e33bde119a5322c6bc76e5c0e48f043.tar.lz pttbbs-5d6d1b984e33bde119a5322c6bc76e5c0e48f043.tar.xz pttbbs-5d6d1b984e33bde119a5322c6bc76e5c0e48f043.tar.zst pttbbs-5d6d1b984e33bde119a5322c6bc76e5c0e48f043.zip |
try to fix strange behavior of bvote
check tmpfile size before save fav4
comment for DDOS
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2322 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | mbbsd/fav.c | 5 | ||||
-rw-r--r-- | mbbsd/mail.c | 1 | ||||
-rw-r--r-- | mbbsd/vote.c | 30 |
3 files changed, 13 insertions, 23 deletions
diff --git a/mbbsd/fav.c b/mbbsd/fav.c index 6b4cd316..daea0c5c 100644 --- a/mbbsd/fav.c +++ b/mbbsd/fav.c @@ -460,7 +460,10 @@ int fav_save(void) "%s %s", cuser.userid, ctime(&now)); return -1; } - Rename(buf, buf2); + + /* to avoid write failed */ + if (dashs(buf) != 0) + Rename(buf, buf2); return 0; } diff --git a/mbbsd/mail.c b/mbbsd/mail.c index 5ba76b17..85b3170f 100644 --- a/mbbsd/mail.c +++ b/mbbsd/mail.c @@ -1389,6 +1389,7 @@ send_inner_mail(char *fpath, char *title, char *receiver) if (!searchuser(receiver)) return -2; + /* to avoid DDOS of disk */ sethomedir(genbuf, receiver); // XXX should we use MAX_EXKEEPMAIL instead? if (dashs(genbuf) >= 2048 * sizeof(fileheader_t)) { diff --git a/mbbsd/vote.c b/mbbsd/vote.c index 029bd581..1268f16f 100644 --- a/mbbsd/vote.c +++ b/mbbsd/vote.c @@ -44,8 +44,10 @@ void convert_first_vote(boardheader_t *fhp) if (dashf(buf2)) continue; // old style format should be removed later - if (link(buf, buf2) < 0) + if (link(buf, buf2) < 0) { vmsg(strerror(errno)); + unlink(buf); + } } } #endif @@ -233,12 +235,6 @@ b_result_one(vote_buffer_t *vbuf, boardheader_t * fh, int ind, int *total) fh->bvote--; - // FIXME wrong range? - if (fh->bvote == 0) - fh->bvote = 2; - else if (fh->bvote == 2) - fh->bvote = 1; - snprintf(vbuf->ballots, sizeof(vbuf->ballots), "%s%d", STR_bv_ballots, ind); snprintf(vbuf->control, sizeof(vbuf->control),"%s%d", STR_bv_control, ind); snprintf(vbuf->desc, sizeof(vbuf->desc), "%s%d", STR_bv_desc, ind); @@ -373,7 +369,7 @@ b_result(vote_buffer_t *vbuf, boardheader_t * fh) static int b_close(boardheader_t * fh, vote_buffer_t *vbuf) { - + // XXX what's it for ? if (fh->bvote == 2) { if (fh->vtime < now - 3 * 86400) { fh->bvote = 0; @@ -519,11 +515,7 @@ vote_view(vote_buffer_t *vbuf, char *bname, int vote_index) setbfile(buf, bname, vbuf->title); unlink(buf); - // XXX is it wrong? - if (fhp->bvote) - fhp->bvote--; - if (fhp->bvote == 2) - fhp->bvote = 1; + fhp->bvote--; if (substitute_record(fn_board, fhp, sizeof(*fhp), pos) == -1) outs(err_board_update); @@ -605,7 +597,9 @@ vote_maintain(char *bname) stand_title("Á|¿ì§ë²¼"); fhp = bcache + pos - 1; - /* CharlieL */ + if (fhp->bvote < 0) + fhp->bvote = 0; + if (fhp->bvote != 0) { #if 1 // convert the filenames of first vote @@ -752,14 +746,6 @@ vote_maintain(char *bname) fprintf(fp, "%3d,%3d\n", x * 30 + num, MAX(1, atoi(inbuf))); fclose(fp); - // XXX fix range - if (fhp->bvote == 2) - fhp->bvote = 0; - else if (fhp->bvote == 1) - fhp->bvote = 2; - else if (fhp->bvote == 2) - fhp->bvote = 1; - fhp->bvote++; if (substitute_record(fn_board, fhp, sizeof(*fhp), pos) == -1) |