diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2007-12-05 21:10:18 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2007-12-05 21:10:18 +0800 |
commit | 1a0fc5606804a41bfa34acdc82f7ec43ef3ae933 (patch) | |
tree | b059d036c5cd06d81c1261780714ccd933a82c1c /mbbsd/screen.c | |
parent | ef6481cca41aca3c247f845ef55a9b2cd491be65 (diff) | |
download | pttbbs-1a0fc5606804a41bfa34acdc82f7ec43ef3ae933.tar pttbbs-1a0fc5606804a41bfa34acdc82f7ec43ef3ae933.tar.gz pttbbs-1a0fc5606804a41bfa34acdc82f7ec43ef3ae933.tar.bz2 pttbbs-1a0fc5606804a41bfa34acdc82f7ec43ef3ae933.tar.lz pttbbs-1a0fc5606804a41bfa34acdc82f7ec43ef3ae933.tar.xz pttbbs-1a0fc5606804a41bfa34acdc82f7ec43ef3ae933.tar.zst pttbbs-1a0fc5606804a41bfa34acdc82f7ec43ef3ae933.zip |
- grayout: check potential (almost impossible) buffer overflow
- pmore: fix message error
- mail: better explain of waterlog re-arrange usage help
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3641 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/screen.c')
-rw-r--r-- | mbbsd/screen.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/mbbsd/screen.c b/mbbsd/screen.c index 4d9159ba..4115c45c 100644 --- a/mbbsd/screen.c +++ b/mbbsd/screen.c @@ -575,6 +575,9 @@ grayout_lines(int y, int end, int level) if (slp->len < 1) continue; + if (slp->len >= ANSILINELEN) + slp->len = ANSILINELEN -1; + // tweak slp slp->data[slp->len] = 0; slp->mode &= ~STANDOUT; @@ -596,6 +599,12 @@ grayout_lines(int y, int end, int level) switch(level) { case 0: // dark text + // basically, in current system slp->data will + // not exceed t_columns. buffer overflow is impossible. + // but to make it more robust, let's quick check here. + // of course, t_columns should always be far smaller. + if (strlen((char*)slp->data) > t_columns) + slp->data[t_columns] = 0; strcpy((char*)slp->data, ANSI_COLOR(1;30;40)); strcat((char*)slp->data, buf); strcat((char*)slp->data, ANSI_RESET ANSI_CLRTOEND); |