From: Pierre Ossman Date: Thu, 17 Aug 2023 12:46:04 +0000 (+0200) Subject: Move custom FLTK box types to valid range X-Git-Tag: v1.13.90~55 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=4cef5c996f18e3688bf13ec1ccee2f22ff888071;p=tigervnc.git Move custom FLTK box types to valid range FLTK only allows 256 different box types, but it doesn't actually check this when registering new ones. Move our custom types to a valid range, and add an assert for good measure to make sure we don't overflow FLTK's internal structures. --- diff --git a/vncviewer/fltk/theme.cxx b/vncviewer/fltk/theme.cxx index f89933a3..22e04dc6 100644 --- a/vncviewer/fltk/theme.cxx +++ b/vncviewer/fltk/theme.cxx @@ -25,6 +25,8 @@ #include #endif +#include + #ifdef WIN32 #include #endif @@ -271,6 +273,9 @@ void init_theme() const int PX = 2; const int PY = 2; + // FLTK lacks a bounds check + assert(THEME_ROUND_DOWN_BOX < 256); + Fl::set_boxtype(THEME_UP_FRAME, theme_up_frame, PX, PY, PX*2, PY*2); Fl::set_boxtype(THEME_DOWN_FRAME, theme_down_frame, PX, PY, PX*2, PY*2); Fl::set_boxtype(THEME_THIN_UP_FRAME, theme_up_frame, PX, PY, PX*2, PY*2); diff --git a/vncviewer/fltk/theme.h b/vncviewer/fltk/theme.h index 8793bd7c..b6a53218 100644 --- a/vncviewer/fltk/theme.h +++ b/vncviewer/fltk/theme.h @@ -26,7 +26,7 @@ #include -#define _THEME_BOX_BASE (FL_FREE_BOXTYPE+1000) +#define _THEME_BOX_BASE (FL_FREE_BOXTYPE+20) #define THEME_UP_FRAME (Fl_Boxtype)(_THEME_BOX_BASE+0) #define THEME_DOWN_FRAME (Fl_Boxtype)(_THEME_BOX_BASE+1)