From 22cc0d5ea55f77ae635bb045f575868c834bac94 Mon Sep 17 00:00:00 2001 From: msw Date: Mar 30 2001 21:45:58 +0000 Subject: - don't blow the stack if we push a help line that is longer than the curret number of columns - clip window to screen bounds so that if we get a window that is larger than the screen we can still redraw the windows behind it when we pop --- diff --git a/configure.in b/configure.in index ea2923b..1ddaa4a 100644 --- a/configure.in +++ b/configure.in @@ -5,7 +5,7 @@ AC_CONFIG_HEADER(config.h) VERSION=$(awk '/^%define version/ {print $3}' newt.spec) -VERSION=0.50.20 +VERSION=0.50.21 SONAME=0.50 AC_SUBST(VERSION) AC_SUBST(SONAME) diff --git a/newt.c b/newt.c index f919c33..42b0371 100644 --- a/newt.c +++ b/newt.c @@ -394,11 +394,20 @@ int newtOpenWindow(int left, int top, int width, int height, row = top - 1; col = left - 1; + /* clip to the current screen bounds - msw */ + if (row < 0) + row = 0; + if (col < 0) + col = 0; + if (left + width > SLtt_Screen_Cols) + width = SLtt_Screen_Cols - left; + if (top + height > SLtt_Screen_Rows) + height = SLtt_Screen_Rows - top; n = 0; for (j = 0; j < height + 3; j++, row++) { SLsmg_gotorc(row, col); SLsmg_read_raw(currentWindow->buffer + n, - currentWindow->width + 3); + currentWindow->width + 3); n += currentWindow->width + 3; } @@ -460,10 +469,14 @@ void newtPopWindow(void) { row = currentWindow->top - 1; col = currentWindow->left - 1; + if (row < 0) + row = 0; + if (col < 0) + col = 0; for (j = 0; j < currentWindow->height + 3; j++, row++) { SLsmg_gotorc(row, col); SLsmg_write_raw(currentWindow->buffer + n, - currentWindow->width + 3); + currentWindow->width + 3); n += currentWindow->width + 3; } @@ -578,9 +591,12 @@ void newtRedrawHelpLine(void) { memset(buf, ' ', SLtt_Screen_Cols); buf[SLtt_Screen_Cols] = '\0'; - if (currentHelpline) - memcpy(buf, *currentHelpline, strlen(*currentHelpline)); - + if (currentHelpline) { + int len = strlen(*currentHelpline); + if (SLtt_Screen_Cols < len) + len = SLtt_Screen_Cols; + memcpy(buf, *currentHelpline, len); + } SLsmg_gotorc(SLtt_Screen_Rows - 1, 0); SLsmg_write_string(buf); } diff --git a/newt.spec b/newt.spec index ddcd1f8..3be4f45 100644 --- a/newt.spec +++ b/newt.spec @@ -1,8 +1,8 @@ Summary: A development library for text mode user interfaces. Name: newt -%define version 0.50.20 +%define version 0.50.21 Version: %{version} -Release: 4 +Release: 1 Copyright: LGPL Group: System Environment/Libraries Source: ftp://ftp.redhat.com/pub/redhat/code/newt/newt-%{version}.tar.gz @@ -105,6 +105,13 @@ rm -rf $RPM_BUILD_ROOT %endif %changelog +* Fri Mar 30 2001 Matt Wilson +- don't blow the stack if we push a help line that is longer than the + curret number of columns +- clip window to screen bounds so that if we get a window that is + larger than the screen we can still redraw the windows behind it + when we pop + * Sun Feb 11 2001 Than Ngo - disable building new-python2 sub package again