~ubuntu-branches/ubuntu/natty/expect-tcl8.3/natty

« back to all changes in this revision

Viewing changes to debian/patches/11-ttyname.dpatch

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2008-07-30 22:33:52 UTC
  • mfrom: (2.1.3 hardy)
  • Revision ID: james.westby@ubuntu.com-20080730223352-43j8vqcvoife73ck
Tags: 5.43.0-6
* Install expectk in expectk-tk8.3. Closes: #492288.
* Include expect scripts in expect-tcl8.3-dev as binaries, not as
  examples. Closes: #461357.
* expect-tcl8.3-dev: Depend on tk8.3-dev.
* Acknowledge NMU. Closes: #443393.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh /usr/share/dpatch/dpatch-run
 
2
## 11-ttyname.dpatch by Ian Jackson <iwj@ubuntu.com>
 
3
##
 
4
## DP: Check before call ttyname, so don't coredump in chroots without /proc.
 
5
## DP: (Closes: #440804).
 
6
 
 
7
@DPATCH@
 
8
 
 
9
diff -Naurp expect-5.43.orig/pty_termios.c expect-5.43/pty_termios.c
 
10
--- expect-5.43.orig/pty_termios.c      2004-05-07 16:46:03.000000000 +0000
 
11
+++ expect-5.43/pty_termios.c   2007-09-04 13:44:20.000000000 +0000
 
12
@@ -366,6 +366,17 @@ exp_init_pty()
 
13
 #define W_OK 02
 
14
 #endif
 
15
 
 
16
+static int ttyname_checked(int fd) {
 
17
+       const char *result;
 
18
+       result= ttyname(fd);
 
19
+       if (!result) {
 
20
+               perror("expect: pty_termios: system configuration problem:"
 
21
+                      " ttyname() failed");
 
22
+               exit(-1);
 
23
+       }
 
24
+       return result;
 
25
+}
 
26
+
 
27
 int
 
28
 exp_getptymaster()
 
29
 {
 
30
@@ -451,7 +462,7 @@ exp_getptymaster()
 
31
        master = open("/dev/ptc",O_RDWR);
 
32
        if (master >= 0) {
 
33
                /* never fails */
 
34
-               slave_name = ttyname(master);
 
35
+               slave_name = ttyname_checked(master);
 
36
        }
 
37
        exp_pty_slave_name = slave_name;
 
38
        return(master);
 
39
@@ -472,7 +483,7 @@ exp_getptymaster()
 
40
                close(slave);
 
41
                return -1;
 
42
        }
 
43
-       strcpy(slave_name, ttyname(slave));
 
44
+       strcpy(slave_name, ttyname_checked(slave));
 
45
        exp_pty_slave_name = slave_name;
 
46
        close(slave);
 
47
        return master;