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 @@ _____________________________________________________________________________
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E7A5AD>: "-" - <20><><EFBFBD><EFBFBD><E0A0A2><EFBFBD><EFBFBD><EFBFBD>, "+" - <20><><EFBFBD><EFBFBD><EFBFBD>, "!" - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E2A2A5><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E7A5AD>: "-" - <20><><EFBFBD><EFBFBD><E0A0A2><EFBFBD><EFBFBD><EFBFBD>, "+" - <20><><EFBFBD><EFBFBD><EFBFBD>, "!" - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E2A2A5><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
_____________________________________________________________________________ _____________________________________________________________________________
+ <20><><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD> sources.h <20> golded.spec. <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> 64-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ᡮઠ<E1A1AE> GCC <20><><EFBFBD>ᨩ 4.*. <20><><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><E0ABAE>
2:5059/37 <20><> <20><><EFBFBD><EFBFBD><E0A5AF><EFBFBD><EFBFBD>.
+ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Gentoo ebuild, ᯠᨡ<E1AFA0> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2:5025/121@fidonet.
+ <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><20> <20><><EFBFBD> <20><><EFBFBD><EFBFBD>᪠ make <20><><EFBFBD><EFBFBD><EFBFBD><><EFBFBD><EBA2A0> <20><><EFBFBD><20><><EFBFBD><E0A0AC>
<20><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><E0A8A0> ᡮન.
! <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2:5025/121@fidonet <20><EFBFBD><EBA4A5><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>, <20><><EFBFBD><EFA7A0><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E2A5AA>
ncurses <20> <20><EFBFBD><E2A4A5><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><><EFBFBD><E9A5AD> Goldnode <20> RDDT <20><><EFBFBD><EFBFBD><EFBFBD> <20><>
<20><><EFBFBD><EFBFBD><><EFBFBD><E1AEAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>.
+ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><E1ABA5><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><E5AEA4><EFBFBD><><20><><EFBFBD><E2AEAC><EFBFBD><EFBFBD><EFBFBD><20><><EFBFBD><EFBFBD><E0A0AD><EFBFBD><EFBFBD><EFBFBD> <20>
<><E4A0A9> sources.h <20> golded.spec. <20><><EFBFBD><EFBFBD> <20><> sources.h <20><EFBFBD><E1AFAE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>
<20><>ନ஢<E0ACA8><E0AEA2><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><20><><EFBFBD><><E1ADA0><EFBFBD>⮢ Golded+.
! <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Golded+ <20><EFBFBD><EBA2AE><EFBFBD> <20><EFBFBD><E8A8A1> <20><EFBFBD><E2A5AD> <20><><EFBFBD><EFBFBD> <20> stderr <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> stdout. <20><EFBFBD> ! <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Golded+ <20><EFBFBD><EBA2AE><EFBFBD> <20><EFBFBD><E8A8A1> <20><EFBFBD><E2A5AD> <20><><EFBFBD><EFBFBD> <20> stderr <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> stdout. <20><EFBFBD>
<20><><EFBFBD><E1ACAE><EFBFBD><EFBFBD><EFBFBD> ⮫쪮 <20><EFBFBD><E8A8A1>, <20><><EFBFBD><EFBFBD><ECA7AE><EFBFBD><><EFBFBD><E1AEAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><EFBFBD><EFBFBD><ECA7AE><EFBFBD><EFBFBD> <20><><EFBFBD><E1ACAE><EFBFBD><EFBFBD><EFBFBD> ⮫쪮 <20><EFBFBD><E8A8A1>, <20><><EFBFBD><EFBFBD><ECA7AE><EFBFBD><><EFBFBD><E1AEAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><EFBFBD><EFBFBD><ECA7AE><EFBFBD><EFBFBD>

View File

@@ -13,8 +13,21 @@ ______________________________________________________________________
Legend: "-" - bugfix, "+" - new feature, "!" - important modification. 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 + 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 ! 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 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 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; char * const buf_end = buf+199;
static char old_status_line[200] = ""; 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; static int called = NO;
const int WIDE= sizeof(buf)>MAXCOL? MAXCOL : sizeof(buf)-1;
HandleGEvent(EVTT_REMOVEVOCBUF); HandleGEvent(EVTT_REMOVEVOCBUF);
@@ -81,13 +82,13 @@ void update_statuslines() {
int help_len = strlen(help); int help_len = strlen(help);
int clk_len = strlen(clkinfo); 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); snprintf(buf,sizeof(buf), "%c%s%-*.*s%s ", goldmark, help, len, len, information, clkinfo);
char *begin = buf; char *begin = buf;
char *obegin = old_status_line; char *obegin = old_status_line;
char *end = (sizeof(buf) > MAXCOL) ? buf + MAXCOL: buf_end; char *end = buf + WIDE;
char *oend = (sizeof(old_status_line) > MAXCOL) ? old_status_line + MAXCOL: old_status_line_end; char *oend = old_status_line + WIDE;
while((*begin != NUL) and (*begin == *obegin) and (begin<buf_end) and (obegin<old_status_line_end)) { while((*begin != NUL) and (*begin == *obegin) and (begin<buf_end) and (obegin<old_status_line_end)) {
++begin; ++begin;
++obegin; ++obegin;
@@ -115,8 +116,8 @@ void update_statuslines() {
wwprintstr(W_STAT, 0,begin-buf, C_STATW, begin); wwprintstr(W_STAT, 0,begin-buf, C_STATW, begin);
if(*help and ((begin - buf) < (help_len-1)) and ((end - buf) > (help_len-1))) if(*help and ((begin - buf) < (help_len-1)) and ((end - buf) > (help_len-1)))
wwprintc(W_STAT, 0,help_len-1, C_STATW, sep); wwprintc(W_STAT, 0,help_len-1, C_STATW, sep);
if(((begin - buf) < (MAXCOL-clk_len)) and ((end - buf) > (MAXCOL-clk_len))) if(((begin - buf) < (WIDE-clk_len)) and ((end - buf) > (WIDE-clk_len)))
wwprintc(W_STAT, 0,MAXCOL-clk_len, C_STATW, sep); wwprintc(W_STAT, 0,WIDE-clk_len, C_STATW, sep);
vposset(row, col); vposset(row, col);
#ifdef GOLD_MOUSE #ifdef GOLD_MOUSE
if(gmou.Row() == MAXROW-1) if(gmou.Row() == MAXROW-1)