diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-04-13 14:07:20 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-04-13 14:07:20 +0800 |
commit | cd394a56028c2e701545b79138077c78e21a0aed (patch) | |
tree | 41c00fffb1819beb3cdca607fc8160ba19c23024 | |
parent | fb535169f7c02b66138ef3bef59add8d86b6cfb0 (diff) | |
download | pttbbs-cd394a56028c2e701545b79138077c78e21a0aed.tar pttbbs-cd394a56028c2e701545b79138077c78e21a0aed.tar.gz pttbbs-cd394a56028c2e701545b79138077c78e21a0aed.tar.bz2 pttbbs-cd394a56028c2e701545b79138077c78e21a0aed.tar.lz pttbbs-cd394a56028c2e701545b79138077c78e21a0aed.tar.xz pttbbs-cd394a56028c2e701545b79138077c78e21a0aed.tar.zst pttbbs-cd394a56028c2e701545b79138077c78e21a0aed.zip |
- (internal) code refine: change [200] to [PATHLEN], [STRLEN], or [ANSILINELEN].
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4153 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | mbbsd/board.c | 2 | ||||
-rw-r--r-- | mbbsd/calendar.c | 2 | ||||
-rw-r--r-- | mbbsd/mbbsd.c | 2 | ||||
-rw-r--r-- | mbbsd/name.c | 4 | ||||
-rw-r--r-- | mbbsd/record.c | 2 | ||||
-rw-r--r-- | mbbsd/syspost.c | 6 | ||||
-rw-r--r-- | mbbsd/xyz.c | 15 |
7 files changed, 17 insertions, 16 deletions
diff --git a/mbbsd/board.c b/mbbsd/board.c index 193fe04c..4d643242 100644 --- a/mbbsd/board.c +++ b/mbbsd/board.c @@ -189,7 +189,7 @@ HasBoardPerm(boardheader_t *bptr) static int b_post_note(void) { - char buf[200], yn[3]; + char buf[PATHLEN], yn[3]; // if(!(currmode & MODE_BOARD)) return DONOTHING; stand_title("自訂注意事項"); diff --git a/mbbsd/calendar.c b/mbbsd/calendar.c index 93394b08..c8ad6994 100644 --- a/mbbsd/calendar.c +++ b/mbbsd/calendar.c @@ -270,7 +270,7 @@ GenerateCalendar(char **buf, int y, int m, int today, event_t * e) int u_editcalendar(void) { - char genbuf[200]; + char genbuf[PATHLEN]; getdata(b_lines - 1, 0, "行事曆 (D)刪除 (E)編輯 (H)說明 [Q]取消?[Q] ", genbuf, 3, LCECHO); diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c index 13e8159c..7174bba8 100644 --- a/mbbsd/mbbsd.c +++ b/mbbsd/mbbsd.c @@ -665,7 +665,7 @@ logattempt(const char *uid, char type) void mkuserdir(const char *userid) { - char genbuf[200]; + char genbuf[PATHLEN]; sethomepath(genbuf, userid); // assume it is a dir, so just check if it is exist if (access(genbuf, F_OK) != 0) diff --git a/mbbsd/name.c b/mbbsd/name.c index 59c9c471..d170eebd 100644 --- a/mbbsd/name.c +++ b/mbbsd/name.c @@ -301,10 +301,10 @@ void ToggleNameList(int *reciper, const char *listfile, const char *msg) { FILE *fp; - char genbuf[200]; + char genbuf[STRLEN]; if ((fp = fopen(listfile, "r"))) { - while (fgets(genbuf, STRLEN, fp)) { + while (fgets(genbuf, sizeof(genbuf), fp)) { char *space = strpbrk(genbuf, str_space); if (space) *space = '\0'; if (!genbuf[0]) diff --git a/mbbsd/record.c b/mbbsd/record.c index 4fe5e076..7f5b95b4 100644 --- a/mbbsd/record.c +++ b/mbbsd/record.c @@ -26,7 +26,7 @@ get_sum_records(const char *fpath, int size) int ans = 0; FILE *fp; fileheader_t fhdr; - char buf[200], *p; + char buf[PATHLEN], *p; // Ptt : should avoid big loop if ((fp = fopen(fpath, "r"))==NULL) diff --git a/mbbsd/syspost.c b/mbbsd/syspost.c index b4d56c73..a1bbffa9 100644 --- a/mbbsd/syspost.c +++ b/mbbsd/syspost.c @@ -104,7 +104,7 @@ void post_violatelaw(const char *crime, const char *police, const char *reason, const char *result) { char title[TTLEN+1]; - char msg[200]; + char msg[ANSILINELEN]; snprintf(title, sizeof(title), "[報告] %s:%-*s 判決", crime, (int)(37 - strlen(reason) - strlen(crime)), reason); @@ -131,7 +131,7 @@ post_violatelaw(const char *crime, const char *police, const char *reason, const void post_newboard(const char *bgroup, const char *bname, const char *bms) { - char genbuf[256], title[TTLEN+1]; + char genbuf[ANSILINELEN], title[TTLEN+1]; snprintf(title, sizeof(title), "[新板成立] %s", bname); snprintf(genbuf, sizeof(genbuf), @@ -144,7 +144,7 @@ post_newboard(const char *bgroup, const char *bname, const char *bms) void post_policelog(const char *bname, const char *atitle, const char *action, const char *reason, const int toggle) { - char genbuf[256], title[TTLEN+1]; + char genbuf[ANSILINELEN], title[TTLEN+1]; snprintf(title, sizeof(title), "[%s][%s] %s by %s", action, toggle ? "開啟" : "關閉", bname, cuser.userid); snprintf(genbuf, sizeof(genbuf), diff --git a/mbbsd/xyz.c b/mbbsd/xyz.c index fd7d5f4e..71783edd 100644 --- a/mbbsd/xyz.c +++ b/mbbsd/xyz.c @@ -238,7 +238,7 @@ static void mail_sysop(void) { FILE *fp; - char genbuf[200]; + char genbuf[STRLEN]; if ((fp = fopen("etc/sysop", "r"))) { int i, j; @@ -251,7 +251,7 @@ mail_sysop(void) sysoplist_t sysoplist[9]; j = 0; - while (fgets(genbuf, 128, fp)) { + while (fgets(genbuf, sizeof(genbuf), fp)) { if ((ptr = strchr(genbuf, '\n'))) { *ptr = '\0'; if ((ptr = strchr(genbuf, ':'))) { @@ -260,8 +260,10 @@ mail_sysop(void) i = *++ptr; } while (i == ' ' || i == '\t'); if (i) { - strcpy(sysoplist[j].userid, genbuf); - strcpy(sysoplist[j++].duty, ptr); + strlcpy(sysoplist[j].userid, genbuf, + sizeof(sysoplist[j].userid)); + strlcpy(sysoplist[j++].duty, ptr, + sizeof(sysoplist[j].duty)); } } } @@ -299,7 +301,7 @@ m_sysop(void) int Goodbye(void) { - char genbuf[100]; + char genbuf[STRLEN]; getdata(b_lines - 1, 0, "您確定要離開【 " BBSNAME " 】嗎(Y/N)?[N] ", genbuf, 3, LCECHO); @@ -324,14 +326,13 @@ Goodbye(void) { int diff = (now - login_start_time) / 60; - sprintf(genbuf, "此次停留時間: %d 小時 %2d 分", + snprintf(genbuf, sizeof(genbuf), "此次停留時間: %d 小時 %2d 分", diff / 60, diff % 60); } if(!(cuser.userlevel & PERM_LOGINOK)) vmsg("尚未完成註冊。如要提昇權限請參考本站公佈欄辦理註冊"); else vmsg(genbuf); - // pressanykey(); u_exit("EXIT "); return QUIT; |