summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2006-03-23 01:57:57 +0800
committerkcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2006-03-23 01:57:57 +0800
commitb102f5f44888896e44c8af86ec4bf759e2565d85 (patch)
tree35de39bfdd67850e37ece7d90310696d9e29e118
parentfd20564209c77de3975e708a5646731d76e62d92 (diff)
downloadpttbbs-b102f5f44888896e44c8af86ec4bf759e2565d85.tar
pttbbs-b102f5f44888896e44c8af86ec4bf759e2565d85.tar.gz
pttbbs-b102f5f44888896e44c8af86ec4bf759e2565d85.tar.bz2
pttbbs-b102f5f44888896e44c8af86ec4bf759e2565d85.tar.lz
pttbbs-b102f5f44888896e44c8af86ec4bf759e2565d85.tar.xz
pttbbs-b102f5f44888896e44c8af86ec4bf759e2565d85.tar.zst
pttbbs-b102f5f44888896e44c8af86ec4bf759e2565d85.zip
Warning, API semantic changes.
searchuser() rejects empty userid. git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3294 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--include/proto.h1
-rw-r--r--mbbsd/cache.c12
-rw-r--r--mbbsd/register.c4
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("抱歉,使用者帳號已經滿了,無法註冊新的帳號");