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/friend.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/friend.c')
-rw-r--r-- | mbbsd/friend.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/mbbsd/friend.c b/mbbsd/friend.c index 180d0c36..16df6633 100644 --- a/mbbsd/friend.c +++ b/mbbsd/friend.c @@ -6,8 +6,8 @@ /* ------------------------------------- */ /* Ptt 其他特別名單的檔名 */ -char special_list[] = "list.0"; -char special_des[] = "ldes.0"; +static char special_list[7] = "list.0"; +static char special_des[7] = "ldes.0"; /* 特別名單的上限 */ static const unsigned int friend_max[8] = { @@ -230,7 +230,7 @@ delete_friend_from_file(const char *file, const char *string, int case_sensitiv void friend_delete(const char *uident, int type) { - char fn[STRLEN]; + char fn[PATHLEN]; setfriendfile(fn, type); delete_friend_from_file(fn, uident, 0); } @@ -289,7 +289,7 @@ friend_editdesc(const char *uident, int type) fclose(nfp); } -inline void friend_load_real(int tosort, int maxf, +static inline void friend_load_real(int tosort, int maxf, short *destn, int *destar, const char *fn) { char genbuf[PATHLEN]; @@ -307,6 +307,7 @@ inline void friend_load_real(int tosort, int maxf, else{ char *strtok_pos; tarray = (int *)malloc(sizeof(int) * maxf); + assert(tarray); --maxf; /* 因為最後一個要填 0, 所以先扣一個回來 */ while( fgets(genbuf, STRLEN, fp) && nFriends < maxf ) if( (p = strtok_r(genbuf, str_space, &strtok_pos)) && @@ -365,7 +366,7 @@ friend_water(const char *message, int type) void friend_edit(int type) { - char fpath[PATHLEN], line[STRLEN], uident[IDLEN + 1]; + char fpath[PATHLEN], line[PATHLEN], uident[IDLEN + 1]; int count, column, dirty; FILE *fp; char genbuf[PATHLEN]; |