#1456 closed defect (fixed)

ttyname_r() does not prefix caller provided buffer with _PATH_DEV string

Reported by: Ken Peters Owned by: Joel Sherrill
Priority: normal Milestone: 4.10
Component: score Version: 4.10
Severity: normal Keywords:
Cc: Blocked By:
Blocking:

Description

ttyname_r() when called directly (not via ttyname()) does not prefix the caller provided buffer with the predefined _PATH_DEV string ("/dev/"). Thus the directory search fails and no tty name is returned to the caller. This can be worked around if the caller pre-fills the buffer with the _PATH_DEV string, but better to fix the problem.

Suggested patch to cpukit/libcsupport/src/ttyname.c:

--- ttyname.c 2009-09-14 09:01:39.000000000 -0700
+++ ttyname_new.c 2009-10-26 16:45:31.000000000 -0700
@@ -82,6 +82,10 @@

if ((dp = opendir (_PATH_DEV)) == NULL)

rtems_set_errno_and_return_minus_one(EBADF);


+ if (name != ttyname_buf) {
+ strncpy (name, _PATH_DEV, namesize);
+ }
+

for (rval = NULL; (dirp = readdir (dp)) != NULL ;)

{

if (dirp->d_ino != sb.st_ino)

Attachments (1)

pr1458.diff (933 bytes) - added by Joel Sherrill on Mar 11, 2010 at 2:51:25 PM.
Patch for 4.10

Download all attachments as: .zip

Change History (2)

Changed on Mar 11, 2010 at 2:51:25 PM by Joel Sherrill

Attachment: pr1458.diff added

Patch for 4.10

comment:1 Changed on Mar 11, 2010 at 6:14:57 PM by Joel Sherrill

Resolution: fixed
Status: newclosed

Committed my version of the patch to CVS head.

Note: See TracTickets for help on using tickets.