diff options
-rw-r--r-- | mbbsd/cal.c | 1 | ||||
-rw-r--r-- | mbbsd/mbbsd.c | 24 |
2 files changed, 13 insertions, 12 deletions
diff --git a/mbbsd/cal.c b/mbbsd/cal.c index 266bac25..4fad13ff 100644 --- a/mbbsd/cal.c +++ b/mbbsd/cal.c @@ -228,6 +228,7 @@ osong(void) /* Jaky 超過 MAX_MOVIE 首歌就開始砍 */ nsongs = get_num_records(OSONGPATH "/.DIR", sizeof(mail)); if (nsongs > MAX_MOVIE) { + // XXX race condition delete_range(OSONGPATH "/.DIR", 1, nsongs - MAX_MOVIE); } snprintf(genbuf, sizeof(genbuf), "%s says \"%s\" to %s.", sender, say, receiver); diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c index 257c925a..eadcc622 100644 --- a/mbbsd/mbbsd.c +++ b/mbbsd/mbbsd.c @@ -1066,23 +1066,23 @@ inline static void foreign_warning(void){ static void user_login(void) { - struct tm ptime, lasttime; + struct tm *ptime, *lasttime; int nowusers, ifbirth = 0, i; /* NOTE! 在 setup_utmp 之前, 不應該有任何 blocking/slow function, * 否則可藉機 race condition 達到 multi-login */ /* get local time */ - ptime = *localtime4(&now); + ptime = localtime4(&now); /* 初始化: random number 增加user跟時間的差異 */ mysrand(); /* check if over18 */ - if( (ptime.tm_year - cuser.year) >= 18 || - (ptime.tm_year - cuser.year == 17 && - ((ptime.tm_mon+1) > cuser.month || - ((ptime.tm_mon+1) == cuser.month && ptime.tm_mday > cuser.day))) ) + if( (ptime->tm_year - cuser.year) >= 18 || + (ptime->tm_year - cuser.year == 17 && + ((ptime->tm_mon+1) > cuser.month || + ((ptime->tm_mon+1) == cuser.month && ptime->tm_mday > cuser.day))) ) over18 = 1; log_usies("ENTER", fromhost); @@ -1109,11 +1109,11 @@ user_login(void) /* 初始化 uinfo、flag、mode */ setup_utmp(LOGIN); enter_uflag = cuser.uflag; - lasttime = *localtime4(&cuser.lastlogin); + lasttime = localtime4(&cuser.lastlogin); /* show welcome_login */ - if( (ifbirth = (ptime.tm_mday == cuser.day && - ptime.tm_mon + 1 == cuser.month)) ){ + if( (ifbirth = (ptime->tm_mday == cuser.day && + ptime->tm_mon + 1 == cuser.month)) ){ more("etc/Welcome_birth", NA); } else { @@ -1156,7 +1156,7 @@ user_login(void) welcome_msg(); if( ifbirth ){ - birthday_make_a_wish(&ptime, &lasttime); + birthday_make_a_wish(ptime, lasttime); if( getans("是否要顯示「壽星」於使用者名單上?(y/N)") == 'y' ) currutmp->birth = 1; } @@ -1179,7 +1179,7 @@ user_login(void) check_mailbox_quota(); } - if(ptime.tm_yday!=lasttime.tm_yday) + if(ptime->tm_yday != lasttime->tm_yday) STATINC(STAT_TODAYLOGIN_MAX); if (!PERM_HIDE(currutmp)) { @@ -1200,7 +1200,7 @@ user_login(void) #endif /* login time update */ - if(ptime.tm_yday!=lasttime.tm_yday) + if(ptime->tm_yday != lasttime->tm_yday) STATINC(STAT_TODAYLOGIN_MIN); |