From 3083762d4c4756707384ae43d4eca630aa61ae20 Mon Sep 17 00:00:00 2001 From: Ianos Gnatiuc Date: Fri, 30 Dec 2005 13:58:46 +0000 Subject: [PATCH] Fixed buffer overun for too wide menus --- docs/notework.txt | 2 ++ goldlib/gall/gwinbase.cpp | 3 +++ goldlib/gall/gwinmenu.cpp | 11 ++++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/docs/notework.txt b/docs/notework.txt index a94c70e..839abc8 100644 --- a/docs/notework.txt +++ b/docs/notework.txt @@ -10,6 +10,8 @@ ______________________________________________________________________ Notes for GoldED+ 1.1.5, /snapshot/ ______________________________________________________________________ +- Fixed buffer overun for too wide menus. + + Added new config file token: XlatCharSetAlias "charset" "alias1" "alias2"... that defines charset aliases for import tables. diff --git a/goldlib/gall/gwinbase.cpp b/goldlib/gall/gwinbase.cpp index f111dda..ea0063e 100644 --- a/goldlib/gall/gwinbase.cpp +++ b/goldlib/gall/gwinbase.cpp @@ -132,6 +132,9 @@ int wopen(int srow, int scol, int erow, int ecol, int btype, int battr, int watt return 0; } + if (ecol >= gvid->numcols) + ecol = gvid->numcols - 1; + // see if window is to have a border int border = (btype==5) ? NO : YES; diff --git a/goldlib/gall/gwinmenu.cpp b/goldlib/gall/gwinmenu.cpp index c3feae9..4d32fe7 100644 --- a/goldlib/gall/gwinmenu.cpp +++ b/goldlib/gall/gwinmenu.cpp @@ -41,6 +41,10 @@ #include #include +#if defined(__USE_ALLOCA__) + #include +#endif + // ------------------------------------------------------------------ @@ -198,10 +202,14 @@ static void close_window(int w) static void disp_item(_item_t *witem,int bar) { +#if defined(__USE_ALLOCA__) + char *buf = (char *)alloca(sizeof(vatch)*gvid->numcols); +#else + __extension__ char buf[sizeof(vatch)*gvid->numcols]; +#endif char ch; int chattr; _wrec_t* whp; - char buf[256]; register const char* p; register vatch* ptr=(vatch*)buf; int i, textend,width,wcol,found=NO; @@ -214,6 +222,7 @@ static void disp_item(_item_t *witem,int bar) width = calc_bar_width(gwin.cmenu,witem); textend = gwin.cmenu->textpos+strlen(p)-1; wgotoxy(witem->wrow,wcol=witem->wcol); + if (width > (gvid->numcols-2)) width = gvid->numcols - 2; // display separators if (witem->fmask & M_SEPAR)