# HG changeset patch # User Ben Wing # Date 1264574643 21600 # Node ID 70e8a00896e9ca34731336906ea9ba467fd3f9f4 # Parent 304aebb79cd3c70fe940d0763fae49ae00a5c68b fix an obscure crash reading from stream devices -------------------- ChangeLog entries follow: -------------------- src/ChangeLog addition: 2010-01-27 Ben Wing * 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. diff -r 304aebb79cd3 -r 70e8a00896e9 src/ChangeLog --- 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 + + * 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 * .gdbinit.in.in: diff -r 304aebb79cd3 -r 70e8a00896e9 src/event-unixoid.c --- 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)