summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2009-06-18 16:00:48 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2009-06-18 16:00:48 +0800
commitf4860f1509a434d9261ac47c4e4e139d92ab9f2c (patch)
treeb7bc9933f0cf9919c9ac6e76d9c41680b353cf19
parent2d5091f543421dbd09f588ed500868578a3cfb50 (diff)
downloadpttbbs-f4860f1509a434d9261ac47c4e4e139d92ab9f2c.tar
pttbbs-f4860f1509a434d9261ac47c4e4e139d92ab9f2c.tar.gz
pttbbs-f4860f1509a434d9261ac47c4e4e139d92ab9f2c.tar.bz2
pttbbs-f4860f1509a434d9261ac47c4e4e139d92ab9f2c.tar.lz
pttbbs-f4860f1509a434d9261ac47c4e4e139d92ab9f2c.tar.xz
pttbbs-f4860f1509a434d9261ac47c4e4e139d92ab9f2c.tar.zst
pttbbs-f4860f1509a434d9261ac47c4e4e139d92ab9f2c.zip
* fix potential negative numposts
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4656 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--mbbsd/bbs.c13
-rw-r--r--mbbsd/passwd.c3
2 files changed, 12 insertions, 4 deletions
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c
index f52d97f8..04b73def 100644
--- a/mbbsd/bbs.c
+++ b/mbbsd/bbs.c
@@ -386,7 +386,10 @@ int CheckPostRestriction(int bid)
return 0;
if (cuser.numlogins / 10 < (unsigned int)bp->post_limit_logins)
return 0;
- if (cuser.numposts / 10 < (unsigned int)bp->post_limit_posts)
+ // XXX numposts itself is an integer, but some records (by del post!?) may
+ // create invalid records as -1... so we'd better make it signed for real
+ // comparison.
+ if ((int)(cuser.numposts / 10) < (int)(unsigned int)bp->post_limit_posts)
return 0;
#ifdef ASSESS
@@ -3226,7 +3229,6 @@ del_post(int ent, fileheader_t * fhdr, char *direct)
if (genbuf[0]=='y') {
int i;
char *userid=getuserid(tusernum);
- int rpt_bid;
move(b_lines - 2, 0);
clrtobot();
@@ -3271,7 +3273,8 @@ del_post(int ent, fileheader_t * fhdr, char *direct)
mail_id(userid, genbuf, newpath, cuser.userid);
#ifdef BAD_POST_RECORD
- rpt_bid = getbnum(BAD_POST_RECORD);
+ {
+ int rpt_bid = getbnum(BAD_POST_RECORD);
if (rpt_bid > 0) {
fileheader_t report_fh;
char report_path[PATHLEN];
@@ -3290,6 +3293,7 @@ del_post(int ent, fileheader_t * fhdr, char *direct)
touchbtotal(rpt_bid);
}
+ }
#endif /* defined(BAD_POST_RECORD) */
}
}
@@ -3328,7 +3332,8 @@ del_post(int ent, fileheader_t * fhdr, char *direct)
{
userec_t xuser;
passwd_sync_query(tusernum, &xuser);
- xuser.numposts--;
+ if (xuser.numposts)
+ xuser.numposts--;
passwd_sync_update(tusernum, &xuser);
sendalert_uid(tusernum, ALERT_PWD_POSTS);
diff --git a/mbbsd/passwd.c b/mbbsd/passwd.c
index d73b5dec..48c87b36 100644
--- a/mbbsd/passwd.c
+++ b/mbbsd/passwd.c
@@ -55,6 +55,9 @@ passwd_sync_update(int num, userec_t * buf)
memcpy(cuser.email, u.email, sizeof(u.email));
}
cuser.numposts += u.numposts - latest_numposts;
+ // XXX bad workaround - but.... let's use it until we've solved the sync issue
+ if ((int)cuser.numposts < 0)
+ cuser.numposts = 0;
currutmp->alerts &= ~ALERT_PWD;
// ALERT_PWD_RELOAD: reload all! No need to write.