From 24b0e23466e096b670b8b59b25f417bbd01967eb Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Wed, 21 Jan 2004 13:49:26 +0000 Subject: [PATCH] * src/graphics.c: + Fixed a buffer overflow due to bad signed/unsigned handling. * src/event.c: + Disallow zero width or height in the X11 driver. + Fixed resizing in ncurses and slang. * THANKS: + Added the Source Mage maintainer. --- THANKS | 1 + src/event.c | 6 ++++-- src/graphics.c | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/THANKS b/THANKS index a518bee..1ac326b 100644 --- a/THANKS +++ b/THANKS @@ -3,6 +3,7 @@ $Id$ Derk-Jan Hartman - Gentoo ebuild file Gildas Bazin - win32 driver improvements Jan Hubicka - aafire +Ladislav Hagara - Source Mage spell Michele Bini - original SDL plasma Philip Balinov - Slackware package Richard Zidlicky - rpm specfile diff --git a/src/event.c b/src/event.c index 0d33643..c47e3df 100644 --- a/src/event.c +++ b/src/event.c @@ -278,7 +278,7 @@ static unsigned int _lowlevel_event(void) h = (xevent.xconfigure.height + x11_font_height / 3) / x11_font_height; - if(w == _caca_width && h == _caca_height) + if(!w || !h || (w == _caca_width && h == _caca_height)) continue; x11_new_width = w; @@ -370,6 +370,7 @@ static unsigned int _lowlevel_event(void) if(_caca_resize_event) { _caca_resize_event = 0; + _caca_resize = 1; return CACA_EVENT_RESIZE; } @@ -553,6 +554,7 @@ static unsigned int _lowlevel_event(void) if(_caca_resize_event) { _caca_resize_event = 0; + _caca_resize = 1; return CACA_EVENT_RESIZE; } @@ -723,7 +725,7 @@ static unsigned int _lowlevel_event(void) #if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) static void _push_event(unsigned int event) { - if(events == EVENTBUF_LEN) + if(!event || events == EVENTBUF_LEN) return; eventbuf[events] = event; events++; diff --git a/src/graphics.c b/src/graphics.c index b50b9f7..9c63575 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -443,9 +443,9 @@ void caca_putstr(int x, int y, char const *s) if(x < 0) { - len -= -x; - if(len < 0) + if(len < (unsigned int)-x) return; + len -= -x; s += -x; x = 0; }