From b36b48c02cb250e74679d8cae9ee4f69d0e0fb00 Mon Sep 17 00:00:00 2001 From: piaip Date: Fri, 9 Sep 2005 01:10:30 +0000 Subject: name complete did not check invalid input. git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3143 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/mail.c | 2 ++ mbbsd/name.c | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/mbbsd/mail.c b/mbbsd/mail.c index 7acc84fe..e15cfd5c 100644 --- a/mbbsd/mail.c +++ b/mbbsd/mail.c @@ -627,6 +627,8 @@ multi_send(char *title) static int multi_reply(int ent, fileheader_t * fhdr, const char *direct) { + /* this is not going to work because FILE_MULTI + * exceeds filemode data width. */ if (!(fhdr->filemode & FILE_MULTI)) return mail_reply(ent, fhdr, direct); diff --git a/mbbsd/name.c b/mbbsd/name.c index 5f6b9c5c..c764fb89 100644 --- a/mbbsd/name.c +++ b/mbbsd/name.c @@ -386,6 +386,7 @@ usercomplete(const char *prompt, char *data) int cwnum, x, y, origx, origy; int clearbot = NA, count = 0, morenum = 0; char ch; + int dashdirty = 0; /* TODO 節省記憶體. (不過這個 function 不常占記憶體...) */ cwbuf = malloc(MAX_USERS * (IDLEN + 1)); @@ -435,7 +436,12 @@ usercomplete(const char *prompt, char *data) move(y, x); continue; - } else if (ch != ' ' && count < STRLEN && isprint((int)ch)) { + } else if (!(count <= IDLEN && isprint((int)ch))) { + + /* invalid input */ + continue; + + } else if (ch != ' ') { int n; @@ -463,6 +469,12 @@ usercomplete(const char *prompt, char *data) int col, len; if (ch == ' ' && cwnum == 1) { + if(dashdirty) + { + move(2,0); + clrtoeol(); + printdash(cwlist, 0); + } strcpy(data, cwlist); move(y, x); outs(data + count); @@ -479,16 +491,18 @@ usercomplete(const char *prompt, char *data) move(2, 0); clrtobot(); printdash("使用者代號一覽表", 0); + dashdirty = 0; if(ch != ' ') { /* no such user */ move(2,0); - outs("無此使用者: "); + outs("* 目前無此使用者:"); outs(data); outs(" "); temp--; *temp = '\0'; + dashdirty = 1; } while (len + col < t_columns-1) { -- cgit v1.2.3