comparison src/event-unixoid.c @ 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 2fd201d73a92
children 2ade80e8c640
comparison
equal deleted inserted replaced
4953:304aebb79cd3 4954:70e8a00896e9
98 98
99 if (CONSOLE_TTY_P (con)) 99 if (CONSOLE_TTY_P (con))
100 ch = Lstream_get_ichar (XLSTREAM (CONSOLE_TTY_DATA (con)->instream)); 100 ch = Lstream_get_ichar (XLSTREAM (CONSOLE_TTY_DATA (con)->instream));
101 else 101 else
102 { 102 {
103 Ibyte byte;
103 /* #### Definitely something strange here. We should be setting 104 /* #### Definitely something strange here. We should be setting
104 the stdio handle unbuffered and reading from it instead of mixing 105 the stdio handle unbuffered and reading from it instead of mixing
105 stdio and raw io calls. */ 106 stdio and raw io calls. */
106 int nread = retry_read (fileno (CONSOLE_STREAM_DATA (con)->in), &ch, 1); 107 int nread = retry_read (fileno (CONSOLE_STREAM_DATA (con)->in),
108 &byte, 1);
107 if (nread <= 0) 109 if (nread <= 0)
108 ch = -1; 110 ch = -1;
111 else
112 ch = byte;
109 } 113 }
110 114
111 if (ch < 0) 115 if (ch < 0)
112 { 116 {
113 /* deleting the console might not be safe right now ... */ 117 /* deleting the console might not be safe right now ... */