From db8a86beab2e84fd10a762aba74b8d3a2a4e7fba Mon Sep 17 00:00:00 2001 From: ptt Date: Tue, 30 Mar 2004 07:45:12 +0000 Subject: passwd bug fixed git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1637 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/passwd.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'mbbsd/passwd.c') diff --git a/mbbsd/passwd.c b/mbbsd/passwd.c index e9c3ccb8..777fd23a 100644 --- a/mbbsd/passwd.c +++ b/mbbsd/passwd.c @@ -57,7 +57,7 @@ passwd_update_money(int num) /* update money only */ if (num < 1 || num > MAX_USERS) return -1; - + sethomefile(path, getuserid(num), ".passwd"); if ((pwdfd = open(path, O_WRONLY)) < 0) @@ -97,10 +97,12 @@ passwd_update(int num, userec_t * buf) int pwdfd; char path[256]; + if(!buf->userid[0]) return -1; + sethomefile(path, buf->userid, ".passwd"); buf->money = moneyof(num); if ((pwdfd = open(path, O_WRONLY|O_CREAT, 0600)) < 0) - exit(1); + return -1; write(pwdfd, buf, sizeof(userec_t)); close(pwdfd); return 0; @@ -124,10 +126,15 @@ int passwd_query(int num, userec_t * buf) { int pwdfd; - char path[256]; + char path[256], *userid; + if (num < 1 || num > MAX_USERS) + return -1; + userid = getuserid(num); - sethomefile(path, getuserid(num), ".passwd"); + if(userid[0]=='\0') return -1; + + sethomefile(path, userid, ".passwd"); if((pwdfd = open(path, O_RDONLY)) < 0) { // copy from index // tempory code, will be removed if(passwd_index_query(num, buf)<0) -- cgit v1.2.3