summaryrefslogtreecommitdiffstats
path: root/mbbsd/stuff.c
diff options
context:
space:
mode:
authorkcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-02-28 17:38:41 +0800
committerkcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-02-28 17:38:41 +0800
commit3109e4876e90d88c3b757f7dbf5a89eee595dbcb (patch)
treefba753f5ae09ba880d101d4210ca512c181f86d2 /mbbsd/stuff.c
parent701d7bf89d729a5e0659ae3d6d50493aab7b15fd (diff)
downloadpttbbs-3109e4876e90d88c3b757f7dbf5a89eee595dbcb.tar
pttbbs-3109e4876e90d88c3b757f7dbf5a89eee595dbcb.tar.gz
pttbbs-3109e4876e90d88c3b757f7dbf5a89eee595dbcb.tar.bz2
pttbbs-3109e4876e90d88c3b757f7dbf5a89eee595dbcb.tar.lz
pttbbs-3109e4876e90d88c3b757f7dbf5a89eee595dbcb.tar.xz
pttbbs-3109e4876e90d88c3b757f7dbf5a89eee595dbcb.tar.zst
pttbbs-3109e4876e90d88c3b757f7dbf5a89eee595dbcb.zip
bug fix: fix the potential of char overflow
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2563 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/stuff.c')
-rw-r--r--mbbsd/stuff.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/mbbsd/stuff.c b/mbbsd/stuff.c
index 3d3b90f8..3e44efdf 100644
--- a/mbbsd/stuff.c
+++ b/mbbsd/stuff.c
@@ -622,16 +622,18 @@ getkey(const char *fmt,...)
return vmsg_lines(b_lines, msg);
}
+/* TODO 極少 caller 用到 format, 考慮拆開成 vmsgf 節省 cpu */
int
vmsg(const char *fmt,...)
{
- char msg[256] = "\033[1;36;44m ◆ ", i;
+ char msg[256] = "\033[1;36;44m ◆ ";
+ int i=14; // 14=strlen(msg)
va_list ap;
va_start(ap, fmt);
- i = vsnprintf(msg + 14, 128, fmt, ap);
+ i += vsnprintf(msg + i, 128, fmt, ap);
va_end(ap);
- for(i = i + 14; i < 71; i++)
- msg[(int)i] = ' ';
+ for(; i < 71; i++)
+ msg[i] = ' ';
strcat(msg + 71,
"\033[33;46m \033[200m\033[1431m\033[506m[按任意鍵繼續]\033[201m \033[m");
return vmsg_lines(b_lines, msg);