Message ID | 20100420093835.GC9079@chrom.inf.tu-dresden.de |
---|---|
State | New |
Headers | show |
Hi, On 20 April 2010 11:38, Bernhard Kauer <kauer@os.inf.tu-dresden.de> wrote: > If a terminal is resized or the VGA model issues a full refresh, curses_update() > is called, which uses mvwaddchnstr() to draw a full line of characters. Unfortunatelly > this routine expects a null-terminated string and early aborts if a null is present > in the line. > > When booting an OS that zeros the VGA text buffer and later pokes single characters, > the console output can become unreadable. The attached patch corrects this bug. I believe this issue has come up before with a similar patch but someone checked their ncurses and they didn't see the same issue. I just checked and here mvwaddchnstr() does not expect a null-terminated string either, but it skips the \0 characters. So probably we should replace them with spaces or something else, I wouldn't like to replace a single library call with 80 calls, it's better to go through the string and replace them, maybe in console_write_ch or somewhere else. Cheers
Hi, > I believe this issue has come up before with a similar patch but well i've submitted such a patch more than two years ago. Unfortunatelly it got never applied, so that I have to patch my Qemu on every update... > someone checked their ncurses and they didn't see the same issue. > I just checked and here mvwaddchnstr() does not expect a null-terminated > string either, but it skips the \0 characters. This is not conforming to the Single UNIX Specification, which states that the string is shown "until a null chtype is encountered". See for example: http://www.opengroup.org/onlinepubs/007908775/xcurses/addchstr.html > So probably we should > replace them with spaces or something else, I wouldn't like to > replace a single library call with 80 calls, it's better to go through > the string and replace them, maybe in console_write_ch or somewhere > else. That would be a one-liner. Should I send such a patch? Thanks, Bernhard
On 04/22/2010 09:08 AM, Bernhard Kauer wrote: > Hi, > > >> I believe this issue has come up before with a similar patch but >> > well i've submitted such a patch more than two years ago. Unfortunatelly > it got never applied, so that I have to patch my Qemu on every update... > > > >> someone checked their ncurses and they didn't see the same issue. >> I just checked and here mvwaddchnstr() does not expect a null-terminated >> string either, but it skips the \0 characters. >> > This is not conforming to the Single UNIX Specification, which states > that the string is shown "until a null chtype is encountered". See for > example: > http://www.opengroup.org/onlinepubs/007908775/xcurses/addchstr.html > > > >> So probably we should >> replace them with spaces or something else, I wouldn't like to >> replace a single library call with 80 calls, it's better to go through >> the string and replace them, maybe in console_write_ch or somewhere >> else. >> > That would be a one-liner. Should I send such a patch? > Yes. Regards, Anthony Liguori > Thanks, > > Bernhard > > > >
diff --git a/curses.c b/curses.c index ed3165e..9bf9265 100644 --- a/curses.c +++ b/curses.c @@ -48,10 +48,12 @@ static int px, py, sminx, sminy, smaxx, smaxy; static void curses_update(DisplayState *ds, int x, int y, int w, int h) { chtype *line; + int i; line = ((chtype *) screen) + y * width; for (h += y; y < h; y ++, line += width) - mvwaddchnstr(screenpad, y, 0, line, width); + for (i = 0; i < width; i++) + mvwaddch(screenpad, y, i, (line[i] & 0xff) ? line[i] : ' '); pnoutrefresh(screenpad, py, px, sminy, sminx, smaxy - 1, smaxx - 1); refresh();
If a terminal is resized or the VGA model issues a full refresh, curses_update() is called, which uses mvwaddchnstr() to draw a full line of characters. Unfortunatelly this routine expects a null-terminated string and early aborts if a null is present in the line. When booting an OS that zeros the VGA text buffer and later pokes single characters, the console output can become unreadable. The attached patch corrects this bug. Bernhard Kauer Signed-off-by: Bernhard Kauer <kauer@tudos.org>