diff options
author | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-03-27 08:53:03 +0800 |
---|---|---|
committer | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-03-27 08:53:03 +0800 |
commit | 3e774d4829229f4132e3b6895b572a117f60c99d (patch) | |
tree | 2f94783d37a64eb4b32ffe16b4b8b60855a63239 /mbbsd/admin.c | |
parent | fc4a128e1360ba9b3098656b35721323f173838f (diff) | |
download | pttbbs-3e774d4829229f4132e3b6895b572a117f60c99d.tar pttbbs-3e774d4829229f4132e3b6895b572a117f60c99d.tar.gz pttbbs-3e774d4829229f4132e3b6895b572a117f60c99d.tar.bz2 pttbbs-3e774d4829229f4132e3b6895b572a117f60c99d.tar.lz pttbbs-3e774d4829229f4132e3b6895b572a117f60c99d.tar.xz pttbbs-3e774d4829229f4132e3b6895b572a117f60c99d.tar.zst pttbbs-3e774d4829229f4132e3b6895b572a117f60c99d.zip |
- code clean up
- enlarge buffer size to prevent overflow
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4030 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/admin.c')
-rw-r--r-- | mbbsd/admin.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/mbbsd/admin.c b/mbbsd/admin.c index d0efa3e1..a69776c2 100644 --- a/mbbsd/admin.c +++ b/mbbsd/admin.c @@ -22,8 +22,8 @@ m_loginmsg(void) getdata_str(23, 0, "設定進站水球:", msg, 56, DOECHO, SHM->loginmsg.last_call_in)) { SHM->loginmsg.pid=currutmp->pid; /*站長不多 就不管race condition */ - strcpy(SHM->loginmsg.last_call_in, msg); - strcpy(SHM->loginmsg.userid, cuser.userid); + strlcpy(SHM->loginmsg.last_call_in, msg, sizeof(SHM->loginmsg.last_call_in)); + strlcpy(SHM->loginmsg.userid, cuser.userid, sizeof(SHM->loginmsg.userid)); } return 0; } @@ -96,12 +96,13 @@ search_key_user(const char *passwdfile, int mode) int ch; int unum = 0; FILE *fp1 = fopen(passwdfile, "r"); - char friendfile[128]="", key[22], *keymatch; + char friendfile[PATHLEN]="", key[22], *keymatch; int keytype = 0; - char isCurrentPwd = 0; + int isCurrentPwd; - isCurrentPwd = (strcmp(passwdfile, FN_PASSWD) == 0) ? 1 : 0; assert(fp1); + + isCurrentPwd = (strcmp(passwdfile, FN_PASSWD) == 0); clear(); if (!mode) { @@ -422,7 +423,7 @@ void merge_dir(const char *dir1, const char *dir2, int isoutter) strcat(fh[pn+i].owner, "."); } qsort(fh, pn+sn, sizeof(fileheader_t), dir_cmp); - sprintf(bakdir,"%s.bak", dir1); + snprintf(bakdir, sizeof(bakdir), "%s.bak", dir1); Rename(dir1, bakdir); for(i=1; i<=pn+sn; i++ ) { |