Another fix bufer overflow in wide screen: status line don't cuting but shorten

This commit is contained in:
Stas Degteff 2011-02-19 02:10:10 +00:00
parent e3217ec9be
commit 81c1d6e91e
3 changed files with 37 additions and 9 deletions

View File

@ -13,8 +13,22 @@ _____________________________________________________________________________
Ž¡®§­ ç¥­¨ï: "-" - ¨á¯à ¢«¥­¨¥, "+" - ­®¢®¥, "!" - áãé¥á⢥­­®¥ ¨§¬¥­¥­¨¥.
_____________________________________________________________________________
+ „ β  ―®α«¥¤­¥£® ¨§¬¥­¥­¨ο ¨α室­λε β¥<CEB2>αβ®Ά  Άβ®― β¨η¥α<C2A5>¨ α®εΰ ­ο¥βαο Ά
δ ©«λ sources.h ¨ golded.spec.
- ˆá¯à ¢«¥­® ¬­®£® ®è¨¡®ª à ¡®âë ¢ ¯ ¬ïâìî, ¯à¨¢®¤¨¢è¨å ª  ¢ à¨©­®¬ã
§ ¢¥à襭¨î ¢ 64-¡¨â­ëå ᡮઠå GCC ¢¥àᨩ 4.*. ‘¯ á¨¡® €­â®­ã ƒ®à«®¢ã
2:5059/37 §  ¡ £à¥¯®àâë.
+ „®¡ ¢«¥­ Gentoo ebuild, ᯠᨡ® ‘¥¬ñ­ã <20> ­¥¢¨­ã 2:5025/121@fidonet.
+ <20>ਠª®¬¯¨«ï樨 ¢ áâப¥ § ¯ã᪠ make ¬®¦­® 㪠§ë¢ âì ­¥áª®«ìª® ¯ à ¬¥â஢
çâ®¡ë ¢ë¡à âì ¢ à¨ ­â ᡮન.
! ‘¥¬ñ­ <20> ­¥¢¨­ 2:5025/121@fidonet ¢ë¤¥«¨« ¢¥áì ª®¤, á¢ï§ ­­ë© á ¡¨¡«¨®â¥ª®©
ncurses ¢ ®â¤¥«ì­ãî ¡¨¡«¨®â¥ªã. ’¥¯¥àì á®®¡é¥­¨ï Goldnode ¨ RDDT ¢¨¤­ë ­ 
ª®­á®«¨ î­¨ªá®¯®¤®¡­ëå Ž‘.
+ „ â  ¯®á«¥¤­¥£® ¨§¬¥­¥­¨ï ¨á室­ëå ⥪á⮢  ¢â®¬ â¨ç¥áª¨ á®åà ­ï¥âáï ¢
ä ©«ë sources.h ¨ golded.spec. „ â  ¨§ sources.h ¨á¯®«ì§ã¥âáï ¯à¨
ä®à¬¨à®¢ ­¨¨ áâப¨ ¢¥àᨨ ¤«ï á­ ¯è®â®¢ Golded+.
! ’¥¯¥àì Golded+ ¢ë¢®¤¨â ®è¨¡ª¨ ç⥭¨ï ª®­ä¨£  ¢ stderr ¢¬¥áâ® stdout. —⮡ë
¯®á¬®âà¥âì ⮫쪮 ®è¨¡ª¨, ¯®«ì§®¢ â¥«ì î­¨ªá®¯®¤®¡­®© Ž‘ ¬®¦¥â ¨á¯®«ì§®¢ âì

View File

@ -13,8 +13,21 @@ ______________________________________________________________________
Legend: "-" - bugfix, "+" - new feature, "!" - important modification.
______________________________________________________________________
- Many mistakes of work in the memory, leading to emergency end of
Golded+ in x64 GCC 4.x builds are corrected. Thank Anton Gorlov
2:5059/37 for debugging and reporting about bugs.
+ Gentoo ebuild is added. Thank for Semen Panevin, 2:5025/121@fidonet.
+ You may run make with several parameters to specify variant of build.
! Semen Panevin, 2:5025/121@fidonet has extracted all code related
with library ncurses in separate library. Now messages of Goldnode
and RDDT are visible on the console of unix-like OS.
+ Date of last change of sources automatically remains in a files
srcdate.h and golded.spec.
srcdate.h and golded.spec. Date from srcdate.h uses for forming
version string for Golded+ snapshot.
! Now Golded+ outputs errors of reading of a config in stderr instead
stdout. To look only errors, the user unix-like OS can use a

View File

@ -41,8 +41,9 @@ void update_statuslines() {
char buf[200]; /* FIXME: it is need to use dinamic arrays in this fuction to prevent buffer overflow or screen garbage */
char * const buf_end = buf+199;
static char old_status_line[200] = "";
char * const old_status_line_end = old_status_line_end+199;
char * const old_status_line_end = old_status_line+199;
static int called = NO;
const int WIDE= sizeof(buf)>MAXCOL? MAXCOL : sizeof(buf)-1;
HandleGEvent(EVTT_REMOVEVOCBUF);
@ -81,13 +82,13 @@ void update_statuslines() {
int help_len = strlen(help);
int clk_len = strlen(clkinfo);
int len = MAXCOL-help_len-clk_len-2;
int len = WIDE-help_len-clk_len-2;
snprintf(buf,sizeof(buf), "%c%s%-*.*s%s ", goldmark, help, len, len, information, clkinfo);
char *begin = buf;
char *obegin = old_status_line;
char *end = (sizeof(buf) > MAXCOL) ? buf + MAXCOL: buf_end;
char *oend = (sizeof(old_status_line) > MAXCOL) ? old_status_line + MAXCOL: old_status_line_end;
char *end = buf + WIDE;
char *oend = old_status_line + WIDE;
while((*begin != NUL) and (*begin == *obegin) and (begin<buf_end) and (obegin<old_status_line_end)) {
++begin;
++obegin;
@ -115,8 +116,8 @@ void update_statuslines() {
wwprintstr(W_STAT, 0,begin-buf, C_STATW, begin);
if(*help and ((begin - buf) < (help_len-1)) and ((end - buf) > (help_len-1)))
wwprintc(W_STAT, 0,help_len-1, C_STATW, sep);
if(((begin - buf) < (MAXCOL-clk_len)) and ((end - buf) > (MAXCOL-clk_len)))
wwprintc(W_STAT, 0,MAXCOL-clk_len, C_STATW, sep);
if(((begin - buf) < (WIDE-clk_len)) and ((end - buf) > (WIDE-clk_len)))
wwprintc(W_STAT, 0,WIDE-clk_len, C_STATW, sep);
vposset(row, col);
#ifdef GOLD_MOUSE
if(gmou.Row() == MAXROW-1)