diff options
-rw-r--r-- | include/proto.h | 1 | ||||
-rw-r--r-- | mbbsd/cache.c | 12 | ||||
-rw-r--r-- | mbbsd/register.c | 4 |
3 files changed, 14 insertions, 3 deletions
diff --git a/include/proto.h b/include/proto.h index fb26c5c4..ae3a7b99 100644 --- a/include/proto.h +++ b/include/proto.h @@ -118,6 +118,7 @@ void brc_addlist(const char* fname); void sort_bcache(void); int getuser(const char *userid, userec_t *xuser); void setuserid(int num, const char *userid); +int dosearchuser(const char *userid, char *rightid); int searchuser(const char *userid, char *rightid); int getbnum(const char *bname); void touchbpostnum(int bid, int delta); diff --git a/mbbsd/cache.c b/mbbsd/cache.c index 8063d80c..2d6fc0dd 100644 --- a/mbbsd/cache.c +++ b/mbbsd/cache.c @@ -192,9 +192,11 @@ remove_from_uhash(int n) #warning "searchuser() average chaining MAX_USERS/(1<<HASH_BITS) times." #endif int -searchuser(const char *userid, char *rightid) +dosearchuser(const char *userid, char *rightid) { int h, p, times; + if(userid[0]=='\0') + return 0; STATINC(STAT_SEARCHUSER); h = StringHash(userid)%(1<<HASH_BITS); p = SHM->hash_head[h]; @@ -211,6 +213,14 @@ searchuser(const char *userid, char *rightid) } int +searchuser(const char *userid, char *rightid) +{ + if(userid[0]=='\0') + return 0; + return dosearchuser(userid, rightid); +} + +int getuser(const char *userid, userec_t *xuser) { int uid; diff --git a/mbbsd/register.c b/mbbsd/register.c index ebfb3bf0..0bb22bda 100644 --- a/mbbsd/register.c +++ b/mbbsd/register.c @@ -143,7 +143,7 @@ setupnewuser(const userec_t *user) clock = now; /* Lazy method : 先找尋已經清除的過期帳號 */ - if ((uid = searchuser("", NULL)) == 0) { + if ((uid = dosearchuser("", NULL)) == 0) { /* 每 1 個小時,清理 user 帳號一次 */ if ((stat(fn_fresh, &st) == -1) || (st.st_mtime < clock - 3600)) { if ((fd = open(fn_fresh, O_RDWR | O_CREAT, 0600)) == -1) @@ -167,7 +167,7 @@ setupnewuser(const userec_t *user) passwd_lock(); - uid = searchuser("", NULL); + uid = dosearchuser("", NULL); if ((uid <= 0) || (uid > MAX_USERS)) { passwd_unlock(); vmsg("抱歉,使用者帳號已經滿了,無法註冊新的帳號"); |