summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-03-30 15:45:12 +0800
committerptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-03-30 15:45:12 +0800
commitdb8a86beab2e84fd10a762aba74b8d3a2a4e7fba (patch)
tree17bf9931af579da90cb55cc93ac5cd9ba6e1cc9d
parentf7580a82e730f46435f9ed3b28ad3d64794123a2 (diff)
downloadpttbbs-db8a86beab2e84fd10a762aba74b8d3a2a4e7fba.tar
pttbbs-db8a86beab2e84fd10a762aba74b8d3a2a4e7fba.tar.gz
pttbbs-db8a86beab2e84fd10a762aba74b8d3a2a4e7fba.tar.bz2
pttbbs-db8a86beab2e84fd10a762aba74b8d3a2a4e7fba.tar.lz
pttbbs-db8a86beab2e84fd10a762aba74b8d3a2a4e7fba.tar.xz
pttbbs-db8a86beab2e84fd10a762aba74b8d3a2a4e7fba.tar.zst
pttbbs-db8a86beab2e84fd10a762aba74b8d3a2a4e7fba.zip
passwd bug fixed
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1637 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--mbbsd/passwd.c15
1 files changed, 11 insertions, 4 deletions
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)