Mercurial > hg > xemacs-beta
changeset 4954:70e8a00896e9
fix an obscure crash reading from stream devices
-------------------- ChangeLog entries follow: --------------------
src/ChangeLog addition:
2010-01-27 Ben Wing <ben@xemacs.org>
* event-unixoid.c (read_event_from_tty_or_stream_desc):
Don't try to write one byte into a four-byte variable, leaving
the rest undefined. This is a recipe for crashing.
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Wed, 27 Jan 2010 00:44:03 -0600 |
parents | 304aebb79cd3 |
children | de64354ffcbf |
files | src/ChangeLog src/event-unixoid.c |
diffstat | 2 files changed, 11 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog Wed Jan 27 00:35:36 2010 -0600 +++ b/src/ChangeLog Wed Jan 27 00:44:03 2010 -0600 @@ -1,3 +1,9 @@ +2010-01-27 Ben Wing <ben@xemacs.org> + + * event-unixoid.c (read_event_from_tty_or_stream_desc): + Don't try to write one byte into a four-byte variable, leaving + the rest undefined. This is a recipe for crashing. + 2010-01-27 Ben Wing <ben@xemacs.org> * .gdbinit.in.in:
--- a/src/event-unixoid.c Wed Jan 27 00:35:36 2010 -0600 +++ b/src/event-unixoid.c Wed Jan 27 00:44:03 2010 -0600 @@ -100,12 +100,16 @@ ch = Lstream_get_ichar (XLSTREAM (CONSOLE_TTY_DATA (con)->instream)); else { + Ibyte byte; /* #### Definitely something strange here. We should be setting the stdio handle unbuffered and reading from it instead of mixing stdio and raw io calls. */ - int nread = retry_read (fileno (CONSOLE_STREAM_DATA (con)->in), &ch, 1); + int nread = retry_read (fileno (CONSOLE_STREAM_DATA (con)->in), + &byte, 1); if (nread <= 0) ch = -1; + else + ch = byte; } if (ch < 0)