diff options
author | victor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-08-16 13:39:17 +0800 |
---|---|---|
committer | victor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-08-16 13:39:17 +0800 |
commit | 46d670eedce001eb79f4ce5cc8f6ffaf2ad83b5d (patch) | |
tree | 70bede25e9ceab2711f456b941b1cad345194dd7 /mbbsd | |
parent | 95bd148f89a965c00b11771ccdf1d7090f4f308a (diff) | |
download | pttbbs-46d670eedce001eb79f4ce5cc8f6ffaf2ad83b5d.tar pttbbs-46d670eedce001eb79f4ce5cc8f6ffaf2ad83b5d.tar.gz pttbbs-46d670eedce001eb79f4ce5cc8f6ffaf2ad83b5d.tar.bz2 pttbbs-46d670eedce001eb79f4ce5cc8f6ffaf2ad83b5d.tar.lz pttbbs-46d670eedce001eb79f4ce5cc8f6ffaf2ad83b5d.tar.xz pttbbs-46d670eedce001eb79f4ce5cc8f6ffaf2ad83b5d.tar.zst pttbbs-46d670eedce001eb79f4ce5cc8f6ffaf2ad83b5d.zip |
include/common.h, mbbsd/friend.c: check buffer size
include/fpg.h: highlight the bug
mbbsd/talk.c: change that odd time_t worked as a boolean to int
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3046 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r-- | mbbsd/friend.c | 28 | ||||
-rw-r--r-- | mbbsd/talk.c | 3 |
2 files changed, 15 insertions, 16 deletions
diff --git a/mbbsd/friend.c b/mbbsd/friend.c index e88b0030..179a0482 100644 --- a/mbbsd/friend.c +++ b/mbbsd/friend.c @@ -163,9 +163,9 @@ friend_append(int type, int count) if ((fp = fopen(sfile, "r")) != NULL) { while (fgets(buf, 80, fp) && (unsigned)count <= friend_max[type]) { - char the_id[15]; + char the_id[IDLEN + 1]; - sscanf(buf, "%s", the_id); // XXX check buffer size + sscanf(buf, "%" toSTR(IDLEN) "s", the_id); if (!file_exist_record(fpath, the_id)) { if ((fp1 = fopen(fpath, "a"))) { flock(fileno(fp1), LOCK_EX); @@ -309,7 +309,7 @@ friend_water(const char *message, int type) userinfo_t *uentp; int tuid; - sscanf(line, "%s", userid); // XXX check buffer size + sscanf(line, "%" toSTR(IDLEN) "s", userid); if ((tuid = searchuser(userid, NULL)) && tuid != usernum && (uentp = (userinfo_t *) search_ulist(tuid)) && isvisible_uid(tuid)) @@ -322,7 +322,7 @@ friend_water(const char *message, int type) void friend_edit(int type) { - char fpath[80], line[80], uident[20]; + char fpath[80], line[80], uident[IDLEN + 1]; int count, column, dirty; FILE *fp; char genbuf[200]; @@ -367,38 +367,38 @@ friend_edit(int type) "(K)刪除整個名單(W)丟水球(Q)結束?[Q]" : "(A)增加 (P)引入其他名單 (Q)結束?[Q]"), uident, 3, LCECHO); - if (*uident == 'a') { + if (uident[0] == 'a') { move(1, 0); usercomplete(msg_uid, uident); if (uident[0] && searchuser(uident, uident) && !InNameList(uident)) { friend_add(uident, type, NULL); dirty = 1; } - } else if (*uident == 'p') { + } else if (uident[0] == 'p') { friend_append(type, count); dirty = 1; - } else if (*uident == 'e' && count) { + } else if (uident[0] == 'e' && count) { move(1, 0); namecomplete(msg_uid, uident); if (uident[0] && InNameList(uident)) { friend_editdesc(uident, type); } - } else if (*uident == 'd' && count) { + } else if (uident[0] == 'd' && count) { move(1, 0); namecomplete(msg_uid, uident); if (uident[0] && InNameList(uident)) { friend_delete(uident, type); dirty = 1; } - } else if (*uident == 'l' && count) + } else if (uident[0] == 'l' && count) more(fpath, YEA); - else if (*uident == 'k' && count) { + else if (uident[0] == 'k' && count) { getdata(2, 0, "整份名單將會被刪除,您確定嗎 (a/N)?", uident, 3, LCECHO); - if (*uident == 'a') + if (uident[0] == 'a') unlink(fpath); dirty = 1; - } else if (*uident == 'w' && count) { + } else if (uident[0] == 'w' && count) { char wall[60]; if (!getdata(0, 0, "群體水球:", wall, sizeof(wall), DOECHO)) continue; @@ -417,7 +417,7 @@ friend_edit(int type) snprintf(genbuf, sizeof(genbuf), "%s.old", fpath); if ((fp = fopen(genbuf, "r"))) { while (fgets(line, 80, fp)) { - sscanf(line, "%s", uident); // XXX check buffer size + sscanf(line, "%" toSTR(IDLEN) "s", uident); sethomefile(genbuf, uident, type == FRIEND_ALOHA ? "aloha" : "postnotify"); del_distinct(genbuf, cuser.userid); @@ -427,7 +427,7 @@ friend_edit(int type) strlcpy(genbuf, fpath, sizeof(genbuf)); if ((fp = fopen(genbuf, "r"))) { while (fgets(line, 80, fp)) { - sscanf(line, "%s", uident); // XXX check buffer size + sscanf(line, "%" toSTR(IDLEN) "s", uident); sethomefile(genbuf, uident, type == FRIEND_ALOHA ? "aloha" : "postnotify"); add_distinct(genbuf, cuser.userid); diff --git a/mbbsd/talk.c b/mbbsd/talk.c index ae889028..fb8cffc7 100644 --- a/mbbsd/talk.c +++ b/mbbsd/talk.c @@ -1732,9 +1732,8 @@ friend_descript(const userinfo_t * uentp, char *desc_buf, int desc_buflen) return space_buf; } -/* XXX 為什麼 diff 是 time_t */ static const char * -descript(int show_mode, const userinfo_t * uentp, time4_t diff) +descript(int show_mode, const userinfo_t * uentp, int diff) { static char description[30]; switch (show_mode) { |