bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: wresize and maxx/maxy short int overflow


From: Thomas Dickey
Subject: Re: wresize and maxx/maxy short int overflow
Date: Mon, 2 Nov 2009 16:26:46 -0500 (EST)

On Mon, 2 Nov 2009, Katarina Machalkova wrote:

Hello, list,

Following is the code snippet:

{
  WINDOW *w
   ...
   LOG << "One: " << w->_maxy << " " << w->_maxx << endl;
   int ret = ::wresize( w, lines, columns );
   LOG << "Two: " << w->_maxy << " " << w->_maxx << endl;
}

maxy/maxx are short ints (NCURSES_SIZE_T, to be more precise), while wresize()
takes "normal" ints as params. Now I'm trying to make the window really big in
Y dimension by setting 'lines' param to value greater than 32 768.

NCURSES_SIZE_T is a signed short just because of binary compatibility...

I can improve this specific case by returning an error if the parameters
go out of bounds (there are some others of course).

The above prints:
One: 3 22
Two: -22207 22

Is this bug in a sense that maxy (maxx respectively) should never become
negative,  or is it responsibility of the application calling wresize to make
sure its params are always in range of short ints and overflow of maxy/maxx
never occurs?

generally the library "should" check its parameters.

(I recall some discussion - xorg is recent - from developers who
insist that libraries shouldn't do this ;-)

Thanks for advice (it's likely PEBCAK what I'm seeing but I'd rather be sure)

hB.
--
 \\\\\              Katarina Machalkova
 \\\\\\\__o          YaST developer
__\\\\\\\'/_          & hedgehog painter


_______________________________________________
Bug-ncurses mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/bug-ncurses


--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net




reply via email to

[Prev in Thread] Current Thread [Next in Thread]