|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31684 dio_tcsetattr implementation leads to misconfigured termios settings
Submitted: 2005-01-25 04:38 UTC Modified: 2005-01-25 14:43 UTC
From: elod at itfais dot com Assigned:
Status: Closed Package: Filesystem function related
PHP Version: 4.3.10 OS: MacOSX 10.3.7
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
41 - 2 = ?
Subscribe to this entry?

 [2005-01-25 04:38 UTC] elod at itfais dot com
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 

Following is a diff of ext/dio.c between the 
distribution version and my modified (and fixed) 

>       memset(&newtio, 0, sizeof(newtio));
>       tcgetattr(f->fd, &newtio);


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-01-25 14:43 UTC]
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
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Fri Feb 03 01:03:42 2023 UTC