summaryrefslogtreecommitdiffstats
path: root/mbbsd/screen.c
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2008-01-05 22:24:15 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2008-01-05 22:24:15 +0800
commit312ac55f526f388f6154c9861f232659d348aae2 (patch)
treecc79a20059db4b61567b2232853efaba11eb9b85 /mbbsd/screen.c
parent0e2068d6d86ca7a398a99737736aa4456f9f531c (diff)
downloadpttbbs-312ac55f526f388f6154c9861f232659d348aae2.tar
pttbbs-312ac55f526f388f6154c9861f232659d348aae2.tar.gz
pttbbs-312ac55f526f388f6154c9861f232659d348aae2.tar.bz2
pttbbs-312ac55f526f388f6154c9861f232659d348aae2.tar.lz
pttbbs-312ac55f526f388f6154c9861f232659d348aae2.tar.xz
pttbbs-312ac55f526f388f6154c9861f232659d348aae2.tar.zst
pttbbs-312ac55f526f388f6154c9861f232659d348aae2.zip
- fix potential exploits (reported by kcwu)
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3795 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/screen.c')
-rw-r--r--mbbsd/screen.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/mbbsd/screen.c b/mbbsd/screen.c
index 88696f8a..ffd5029b 100644
--- a/mbbsd/screen.c
+++ b/mbbsd/screen.c
@@ -53,8 +53,12 @@ resizeterm(int w, int h)
void
move(int y, int x)
{
- assert(y>=0);
- assert(x>=0);
+ if (y < 0) y = 0;
+ if (y >= t_lines) y = t_lines -1;
+ if (x < 0) x = 0;
+ if (x >= ANSILINELEN) x = ANSILINELEN -1;
+ // assert(y>=0);
+ // assert(x>=0);
cur_col = x;
cur_ln = y;
}
@@ -64,6 +68,11 @@ move_ansi(int y, int x)
{
// take ANSI length in consideration
register screenline_t *slp;
+ if (y < 0) y = 0;
+ if (y >= t_lines) y = t_lines -1;
+ if (x < 0) x = 0;
+ if (x >= ANSILINELEN) x = ANSILINELEN -1;
+
cur_ln = y;
cur_col = x;
@@ -385,6 +394,10 @@ outc(unsigned char c)
register screenline_t *slp = GetCurrentLine();
register int i;
+ // 0xFF is invalid for most cases (even DBCS),
+ if (c == 0xFF || c == 0x00)
+ return;
+
if (c == '\n' || c == '\r') {
if (standing) {
slp->eso = MAX(slp->eso, cur_col);