Group :: Development/Tcl
RPM: expect
Main Changelog Spec Patches Sources Download Gear Bugs and FR Repocop
Patch: 11-ttyname.patch
Download
Download
Author: Ian Jackson <iwj@ubuntu.com>
Description:
Check before call ttyname, so don't coredump in chroots without /proc
(Closes: #440804).
--- a/pty_termios.c
+++ b/pty_termios.c
@@ -369,6 +369,17 @@
#define W_OK 02
#endif
+static int ttyname_checked(int fd) {
+ const char *result;
+ result= ttyname(fd);
+ if (!result) {
+ perror("expect: pty_termios: system configuration problem:"
+ " ttyname() failed");
+ exit(-1);
+ }
+ return result;
+}
+
int
exp_getptymaster()
{
@@ -454,7 +465,7 @@
master = open("/dev/ptc",O_RDWR);
if (master >= 0) {
/* never fails */
- slave_name = ttyname(master);
+ slave_name = ttyname_checked(master);
}
exp_pty_slave_name = slave_name;
return(master);
@@ -475,7 +486,7 @@
close(slave);
return -1;
}
- strcpy(slave_name, ttyname(slave));
+ strcpy(slave_name, ttyname_checked(slave));
exp_pty_slave_name = slave_name;
close(slave);
return master;