From 0bf17643b07798d26cadeb927bde8db6c4f9fd0d Mon Sep 17 00:00:00 2001 From: piaip Date: Sun, 24 Feb 2008 03:34:47 +0000 Subject: - admin: fixed: searching user generates wrong unum git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3945 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/admin.c | 15 ++++++++------- mbbsd/user.c | 10 ++++++++++ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/mbbsd/admin.c b/mbbsd/admin.c index e1851202..82b8b9b1 100644 --- a/mbbsd/admin.c +++ b/mbbsd/admin.c @@ -94,7 +94,7 @@ search_key_user(const char *passwdfile, int mode) { userec_t user; int ch; - int coun = 0; + int unum = 0; FILE *fp1 = fopen(passwdfile, "r"); char friendfile[128]="", key[22], *keymatch; int keytype = 0; @@ -120,15 +120,15 @@ search_key_user(const char *passwdfile, int mode) fclose(fp1); return 0; } - while ((fread(&user, sizeof(user), 1, fp1)) > 0 && coun < MAX_USERS) { + while ((fread(&user, sizeof(user), 1, fp1)) > 0 && unum++ < MAX_USERS) { // skip empty records if (!user.userid[0]) continue; - if (!(++coun & 0xFF)) { + if (!(unum & 0xFF)) { move(1, 0); - prints("第 [%d] 筆資料\n", coun); + prints("第 [%d] 筆資料\n", unum); refresh(); } @@ -169,14 +169,14 @@ search_key_user(const char *passwdfile, int mode) if(keymatch) { move(1, 0); - prints("第 [%d] 筆資料\n", coun); + prints("第 [%d] 筆資料\n", unum); refresh(); user_display(&user, 1); // user_display does not have linefeed in tail. - // + if (HasUserPerm(PERM_ACCOUNTS)) - uinfo_query(&user, 1, coun); + uinfo_query(&user, 1, unum); else outs("\n"); @@ -1623,6 +1623,7 @@ typedef struct { // [5] email: x (50) (deprecated) // [6] mobile: (deprecated) // [7] ---- + // lasthost: 16 char userid[IDLEN+1]; char exist; diff --git a/mbbsd/user.c b/mbbsd/user.c index 45b162d7..cfcc168a 100644 --- a/mbbsd/user.c +++ b/mbbsd/user.c @@ -681,6 +681,16 @@ uinfo_query(userec_t *u, int adminmode, int unum) fail = 0; mail_changed = money_changed = perm_changed = 0; + { + // verify unum + int xuid = getuser(u->userid, &x); + if (xuid != unum) + { + vmsg("系統錯誤: 使用者資料號碼 (unum) 不合。請至 " GLOBAL_BUGREPORT "報告。"); + return; + } + } + memcpy(&x, u, sizeof(userec_t)); ans = getans(adminmode ? "(1)改資料(2)密碼(3)權限(4)砍帳號(5)改ID(6)寵物(7)審判(M)信箱 [0]結束 " : -- cgit v1.2.3