public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/10784] New: expect fails when calling ttyname on a serial port
@ 2009-10-15 16:48 jaredtsmith at gmail dot com
2009-10-15 16:49 ` [Bug libc/10784] " jaredtsmith at gmail dot com
2009-10-29 18:04 ` drepper at redhat dot com
0 siblings, 2 replies; 4+ messages in thread
From: jaredtsmith at gmail dot com @ 2009-10-15 16:48 UTC (permalink / raw)
To: glibc-bugs
With the file:
glibc-2.9/sysdeps/unix/sysv/linux/ttyname.c
I found that it can get failures in getttyname it has the variable
getttyname_name that is re-used where it allocates a big enough chunk of
memory and then re-uses it the problem is that it doesn't re-copy dev into the
variable if it changes so you can end up in a situation with expect where the
tty changes from /dev/ttys0 --> /dev/pts/1 however the way the code is written
it will append 1 into /dev/ttys0 since it doesn't copy in /dev/pts as it
should. This causes it to return null and crash in expect.
Here is the patch I created for the issue:
diff -ruN glibc-2.9/sysdeps/unix/sysv/linux/ttyname.c glibc-2.9-
fixed/sysdeps/unix/sysv/linux/ttyname.c
--- glibc-2.9/sysdeps/unix/sysv/linux/ttyname.c 2006-12-05 15:25:29.000000000 -
0600
+++ glibc-2.9-fixed/sysdeps/unix/sysv/linux/ttyname.c 2009-10-15
10:12:20.000000000 -0500
@@ -79,7 +79,21 @@
return NULL;
}
*((char *) __mempcpy (getttyname_name, dev, devlen - 1)) = '/';
- }
+ }else{
+ // Need to copy dev string into the buffer. The
+ // variable is a static so it carries the value between
+ // calls and there are situations where the tty can change
+ // for example when running expect on a serial line it will
+ // switch from /dev/ttys0 --> /dev/pty/x without this fix
+ // expect will fail on a serial line as it ends up turning
+ // /dev/ttys0 --> /dev/ttysx which is not valid causing it
+ // to return a null value and fail.
+ memcpy(getttyname_name, dev, devlen); //copy the string
plus the null terminator
+ // The memcpy call following this to copy in d->d_name
expects a trailing "/" to
+ // be appended without that it will be off by one
+ getttyname_name[devlen-1]='/'; //append the
trailing "/"
+ getttyname_name[devlen]='\0'; //NULL terminate the
string
+ }
memcpy (&getttyname_name[devlen], d->d_name, dlen);
if (__xstat64 (_STAT_VER, getttyname_name, &st) == 0
#ifdef _STATBUF_ST_RDEV
--
Summary: expect fails when calling ttyname on a serial port
Product: glibc
Version: 2.9
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: jaredtsmith at gmail dot com
CC: glibc-bugs at sources dot redhat dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=10784
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libc/10784] expect fails when calling ttyname on a serial port
2009-10-15 16:48 [Bug libc/10784] New: expect fails when calling ttyname on a serial port jaredtsmith at gmail dot com
@ 2009-10-15 16:49 ` jaredtsmith at gmail dot com
2009-10-29 18:04 ` drepper at redhat dot com
1 sibling, 0 replies; 4+ messages in thread
From: jaredtsmith at gmail dot com @ 2009-10-15 16:49 UTC (permalink / raw)
To: glibc-bugs
------- Additional Comments From jaredtsmith at gmail dot com 2009-10-15 16:49 -------
Created an attachment (id=4286)
--> (http://sourceware.org/bugzilla/attachment.cgi?id=4286&action=view)
This is another copy of the patch
--
http://sourceware.org/bugzilla/show_bug.cgi?id=10784
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libc/10784] expect fails when calling ttyname on a serial port
2009-10-15 16:48 [Bug libc/10784] New: expect fails when calling ttyname on a serial port jaredtsmith at gmail dot com
2009-10-15 16:49 ` [Bug libc/10784] " jaredtsmith at gmail dot com
@ 2009-10-29 18:04 ` drepper at redhat dot com
1 sibling, 0 replies; 4+ messages in thread
From: drepper at redhat dot com @ 2009-10-29 18:04 UTC (permalink / raw)
To: glibc-bugs
------- Additional Comments From drepper at redhat dot com 2009-10-29 18:04 -------
I've checked in a more efficient patch.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
http://sourceware.org/bugzilla/show_bug.cgi?id=10784
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libc/10784] expect fails when calling ttyname on a serial port
[not found] <bug-10784-131@http.sourceware.org/bugzilla/>
@ 2014-07-01 5:40 ` fweimer at redhat dot com
0 siblings, 0 replies; 4+ messages in thread
From: fweimer at redhat dot com @ 2014-07-01 5:40 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=10784
Florian Weimer <fweimer at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Flags| |security-
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-07-01 5:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-15 16:48 [Bug libc/10784] New: expect fails when calling ttyname on a serial port jaredtsmith at gmail dot com
2009-10-15 16:49 ` [Bug libc/10784] " jaredtsmith at gmail dot com
2009-10-29 18:04 ` drepper at redhat dot com
[not found] <bug-10784-131@http.sourceware.org/bugzilla/>
2014-07-01 5:40 ` fweimer at redhat dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).