summaryrefslogtreecommitdiffstats
path: root/mbbsd
diff options
context:
space:
mode:
authorkcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-02-12 12:16:35 +0800
committerkcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-02-12 12:16:35 +0800
commitfda6d63bafd474518327879633b2231a5aaa6825 (patch)
tree5b3d291865da567e4ff0592facb0d58913a480bb /mbbsd
parent3f76b17cecfae6af61240a7ef9e5f21118e39f40 (diff)
downloadpttbbs-fda6d63bafd474518327879633b2231a5aaa6825.tar
pttbbs-fda6d63bafd474518327879633b2231a5aaa6825.tar.gz
pttbbs-fda6d63bafd474518327879633b2231a5aaa6825.tar.bz2
pttbbs-fda6d63bafd474518327879633b2231a5aaa6825.tar.lz
pttbbs-fda6d63bafd474518327879633b2231a5aaa6825.tar.xz
pttbbs-fda6d63bafd474518327879633b2231a5aaa6825.tar.zst
pttbbs-fda6d63bafd474518327879633b2231a5aaa6825.zip
rewrite few lines.
comment on strange lines. git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2496 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r--mbbsd/admin.c2
-rw-r--r--mbbsd/bbs.c4
-rw-r--r--mbbsd/cache.c29
-rw-r--r--mbbsd/cal.c3
-rw-r--r--mbbsd/mbbsd.c7
5 files changed, 21 insertions, 24 deletions
diff --git a/mbbsd/admin.c b/mbbsd/admin.c
index 01b4e3db..f2c6271b 100644
--- a/mbbsd/admin.c
+++ b/mbbsd/admin.c
@@ -1343,7 +1343,7 @@ give_id_money(char *user_id, int money, FILE * log_fp, char *mail_title, time4_t
{
char tt[TTLEN + 1] = {0};
- if (deumoney(searchuser(user_id), money) < 0) {
+ if (deumoney(searchuser(user_id), money) < 0) { // FIXME if searchuser() return 0
move(12, 0);
clrtoeol();
prints("id:%s money:%d 不對吧!!", user_id, money);
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c
index 71f1829b..dab735e2 100644
--- a/mbbsd/bbs.c
+++ b/mbbsd/bbs.c
@@ -2322,7 +2322,7 @@ good_post(int ent, fileheader_t * fhdr, char *direct)
fhdr->filemode = (fhdr->filemode & ~FILE_DIGEST);
if (!strcmp(currboard, "Note") || !strcmp(currboard, "PttBug") ||
!strcmp(currboard, "Artdsn") || !strcmp(currboard, "PttLaw")) {
- deumoney(searchuser(fhdr->owner), -1000);
+ deumoney(searchuser(fhdr->owner), -1000); // FIXME if searchuser() return 0
if (!(currmode & MODE_SELECT))
fhdr->multi.money -= 1000;
else
@@ -2361,7 +2361,7 @@ good_post(int ent, fileheader_t * fhdr, char *direct)
fhdr->filemode = (fhdr->filemode & ~FILE_MARKED) | FILE_DIGEST;
if (!strcmp(currboard, "Note") || !strcmp(currboard, "PttBug") ||
!strcmp(currboard, "Artdsn") || !strcmp(currboard, "PttLaw")) {
- deumoney(searchuser(fhdr->owner), 1000);
+ deumoney(searchuser(fhdr->owner), 1000); // FIXME if searchuser() return 0
if (!(currmode & MODE_SELECT))
fhdr->multi.money += 1000;
else
diff --git a/mbbsd/cache.c b/mbbsd/cache.c
index c5936331..3f989885 100644
--- a/mbbsd/cache.c
+++ b/mbbsd/cache.c
@@ -555,17 +555,14 @@ reload_bcache(void)
for( i = 0 ; i < MAX_BOARD ; ++i )
if( SHM->bcache[i].brdname[0] ){
char fn[128];
- struct stat st;
+ int n;
sprintf(fn, "boards/%c/%s/.DIR.bottom",
SHM->bcache[i].brdname[0],
SHM->bcache[i].brdname);
- if( stat(fn, &st) == -1 )
- SHM->n_bottom[i] = 0;
- else {
- SHM->n_bottom[i] = st.st_size / sizeof(fileheader_t);
- if( SHM->n_bottom[i] > 5 )
- SHM->n_bottom[i] = 5;
- }
+ n = get_num_records(fn, sizeof(fileheader_t));
+ if( n > 5 )
+ n = 5;
+ SHM->n_bottom[i] = n;
}
}
@@ -608,7 +605,6 @@ reset_board(int bid) /* XXXbid: from 1 */
safe_sleep(1);
} else {
SHM->busystate_b[bid] = COMMON_TIME;
- nuser = bcache[bid].nuser;
bhdr = bcache;
bhdr += bid;
@@ -757,9 +753,8 @@ void buildBMcache(int bid) /* bid starts from 1 */
{
char s[IDLEN * 3 + 3], *ptr;
int i, uid;
- --bid;
- strncpy(s, bcache[bid].BM, sizeof(s));
+ strlcpy(s, bcache[bid-1].BM, sizeof(s));
for( i = 0 ; s[i] != 0 ; ++i )
if( !isalpha((int)s[i]) && !isdigit((int)s[i]) )
s[i] = ' ';
@@ -768,14 +763,15 @@ void buildBMcache(int bid) /* bid starts from 1 */
i < MAX_BMs && ptr != NULL ;
ptr = strtok(NULL, " "), ++i )
if( (uid = searchuser(ptr)) != 0 )
- SHM->BMcache[bid][i] = uid;
+ SHM->BMcache[bid-1][i] = uid;
for( ; i < MAX_BMs ; ++i )
- SHM->BMcache[bid][i] = -1;
+ SHM->BMcache[bid-1][i] = -1;
}
int is_BM_cache(int bid) /* bid starts from 1 */
{
--bid;
+ // XXX hard coded MAX_BMs=4
if( currutmp->uid == SHM->BMcache[bid][0] ||
currutmp->uid == SHM->BMcache[bid][1] ||
currutmp->uid == SHM->BMcache[bid][2] ||
@@ -822,8 +818,8 @@ reload_pttcache(void)
subitem.filename);
if (!(fp2 = fopen(buf, "r")))
continue;
- fread(SHM->notes[id], sizeof(char), 200 * 11, fp2);
- SHM->notes[id][200 * 11 - 1] = 0;
+ fread(SHM->notes[id], sizeof(char), sizeof(SHM->notes[0]), fp2);
+ SHM->notes[id][sizeof(SHM->notes[0]) - 1] = 0;
id++;
fclose(fp2);
if (id >= MAX_MOVIE)
@@ -986,7 +982,7 @@ hbflreload(int bid)
fclose(fp);
}
hbfl[0] = COMMON_TIME;
- memcpy(SHM->hbfl[bid], hbfl, sizeof(hbfl));
+ memcpy(SHM->hbfl[bid], hbfl, sizeof(hbfl)); // FIXME bid-1 ?
}
int
@@ -994,6 +990,7 @@ hbflcheck(int bid, int uid)
{
int i;
+ // FIXME bid-1?
if (SHM->hbfl[bid][0] < login_start_time - HBFLexpire)
hbflreload(bid);
for (i = 1; SHM->hbfl[bid][i] != 0 && i <= MAX_FRIEND; ++i) {
diff --git a/mbbsd/cal.c b/mbbsd/cal.c
index 78011f5f..34eb3ea7 100644
--- a/mbbsd/cal.c
+++ b/mbbsd/cal.c
@@ -292,6 +292,7 @@ p_exmail()
char ans[4], buf[200];
int n;
+ assert(MAX_EXKEEPMAIL < (1<< (sizeof(cuser.exmailbox)*8-1) ));
if (cuser.exmailbox >= MAX_EXKEEPMAIL) {
vmsg("容量最多增加 %d 封,不能再買了。", MAX_EXKEEPMAIL);
return 0;
@@ -373,7 +374,7 @@ p_give()
tax = give_tax(money);
if (money - tax <= 0)
return 0; /* 繳完稅就沒錢給了 */
- deumoney(searchuser(id), money - tax);
+ deumoney(searchuser(id), money - tax); // FIXME if searchuser(id) return 0
demoney(-money);
log_file(FN_MONEY, LOG_CREAT | LOG_VF, "%s\t給%s\t%d\t%s",
cuser.userid, id, money - tax, ctime4(&now));
diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c
index 935111d7..9fc9225f 100644
--- a/mbbsd/mbbsd.c
+++ b/mbbsd/mbbsd.c
@@ -818,9 +818,8 @@ inline static void birthday_make_a_wish(struct tm *ptime, struct tm *tmp){
}
}
-inline static void record_lasthost(char *fromhost, int len){
- strncpy(cuser.lasthost, fromhost, len);
- cuser.lasthost[len - 1] = '\0';
+inline static void record_lasthost(char *fromhost){
+ strlcpy(cuser.lasthost, fromhost, sizeof(cuser.lasthost));
}
inline static void check_mailbox_quota(void){
@@ -956,7 +955,7 @@ user_login()
check_bad_login();
check_mailbox_quota();
check_register();
- record_lasthost(fromhost, 16);
+ record_lasthost(fromhost);
restore_backup();
} else if (!strcmp(cuser.userid, STR_GUEST)) {
init_guest_info();