1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
$NetBSD: patch-bb,v 1.1.1.1 2005/01/02 02:51:43 cube Exp $
--- pppd/tty.c.orig 2004-11-13 13:07:29.000000000 +0100
+++ pppd/tty.c
@@ -80,7 +80,6 @@
#include <fcntl.h>
#include <syslog.h>
#include <netdb.h>
-#include <utmp.h>
#include <pwd.h>
#include <setjmp.h>
#include <sys/param.h>
@@ -216,8 +215,11 @@ option_t tty_options[] = {
"Disable hardware flow control",
OPT_PRIOSUB | OPT_ALIAS | OPT_NOARG | OPT_VAL(-1) },
{ "nocdtrcts", o_int, &crtscts,
- "Disable hardware flow control",
- OPT_PRIOSUB | OPT_ALIAS | OPT_NOARG | OPT_VAL(-1) },
+ "Disable alternate hardware (DTR/CTS) flow control",
+ OPT_PRIOSUB | OPT_NOARG | OPT_VAL(2) },
+ { "-cdtrcts", o_int, &crtscts,
+ "Disable alternate hardware (DTR/CTS) flow control",
+ OPT_PRIOSUB | OPT_ALIAS | OPT_NOARG | OPT_VAL(2) },
{ "xonxoff", o_special_noarg, (void *)setxonxoff,
"Set software (XON/XOFF) flow control", OPT_PRIOSUB },
@@ -840,7 +842,7 @@ finish_tty()
#ifndef __linux__
if (tty_mode != (mode_t) -1) {
if (fchmod(real_ttyfd, tty_mode) != 0)
- error("Couldn't restore tty permissions");
+ warn("Couldn't restore tty permissions: %m");
}
#endif /* __linux__ */
@@ -1097,17 +1099,29 @@ charshunt(ifd, ofd, record_file)
if (nibuf != 0) {
if (ilevel >= max_level)
top = &tout;
- else
+ else {
+ if (pty_master >= FD_SETSIZE)
+ fatal("descriptor too big");
FD_SET(pty_master, &writey);
- } else if (stdin_readable)
+ }
+ } else if (stdin_readable) {
+ if (ifd >= FD_SETSIZE)
+ fatal("descriptor too big");
FD_SET(ifd, &ready);
+ }
if (nobuf != 0) {
if (olevel >= max_level)
top = &tout;
- else
+ else {
+ if (ofd >= FD_SETSIZE)
+ fatal("descriptor too big");
FD_SET(ofd, &writey);
- } else if (pty_readable)
+ }
+ } else if (pty_readable) {
+ if (pty_master >= FD_SETSIZE)
+ fatal("descriptor too big");
FD_SET(pty_master, &ready);
+ }
if (select(nfds, &ready, &writey, NULL, top) < 0) {
if (errno != EINTR)
fatal("select");
@@ -1145,6 +1159,8 @@ charshunt(ifd, ofd, record_file)
if (!record_write(recordf, 4, NULL, 0, &lasttime))
recordf = NULL;
} else {
+ if (pty_master >= FD_SETSIZE)
+ fatal("descriptor too big");
FD_SET(pty_master, &writey);
if (recordf)
if (!record_write(recordf, 2, ibufp, nibuf, &lasttime))
@@ -1172,6 +1188,8 @@ charshunt(ifd, ofd, record_file)
if (!record_write(recordf, 3, NULL, 0, &lasttime))
recordf = NULL;
} else {
+ if (ofd >= FD_SETSIZE)
+ fatal("descriptor too big");
FD_SET(ofd, &writey);
if (recordf)
if (!record_write(recordf, 1, obufp, nobuf, &lasttime))
|