#31684 [Opn->Csd]: dio_tcsetattr implementation leads to misconfigured termios settings
| From: | sniper@php.net | Date: | Tue, 25 Jan 2005 13:43:59 +0000 |
| Subject: | #31684 [Opn->Csd]: dio_tcsetattr implementation leads to misconfigured termios settings | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-72780@lists.php.net to get a copy of this message | ||
ID: 31684
Updated by: sniper@php.net
Reported By: elod at itfais dot com
-Status: Open
+Status: Closed
Bug Type: Filesystem function related
Operating System: MacOSX 10.3.7
PHP Version: 4.3.10
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2005-01-25 04:38:37] elod at itfais dot com
Description:
------------
The implementation of dio_tcsetattr misuses the
tcsetattr() function call for setting termios parameters
on a descriptor. It fills an uninitialized stack local
termios structure with parameters gleened from input to
the dio_tcsetattr() function call while leaving all
other paramters uninitialized. This can (and does) lead
to unpredictable behavior on the device when default
settings are overwritten with garbage.
The correct way to set termio structure information is
to first _get_ the current termios settings
(tcgetattr) on the device, then modifying only the flags
necessary, and then setting the modified termios with
tcsetattr().
Following is a diff of ext/dio.c between the
distribution version and my modified (and fixed)
version:
598a599,600
> memset(&newtio, 0, sizeof(newtio));
> tcgetattr(f->fd, &newtio);
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=31684&edit=1