OpenCoverage

ttymodes.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssh/src/ttymodes.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6static int-
7speed_to_baud(speed_t speed)-
8{-
9 switch (speed) {-
10 case
never executed: case 0000000 :
never executed: case 0000000 :
0
11 0000000
never executed: case 0000000 :
0
12 :
never executed: case 0000000 :
0
13 return
never executed: return 0;
0;
never executed: return 0;
0
14 case
never executed: case 0000001 :
never executed: case 0000001 :
0
15 0000001
never executed: case 0000001 :
0
16 :
never executed: case 0000001 :
0
17 return
never executed: return 50;
50;
never executed: return 50;
0
18 case
never executed: case 0000002 :
never executed: case 0000002 :
0
19 0000002
never executed: case 0000002 :
0
20 :
never executed: case 0000002 :
0
21 return
never executed: return 75;
75;
never executed: return 75;
0
22 case
never executed: case 0000003 :
never executed: case 0000003 :
0
23 0000003
never executed: case 0000003 :
0
24 :
never executed: case 0000003 :
0
25 return
never executed: return 110;
110;
never executed: return 110;
0
26 case
never executed: case 0000004 :
never executed: case 0000004 :
0
27 0000004
never executed: case 0000004 :
0
28 :
never executed: case 0000004 :
0
29 return
never executed: return 134;
134;
never executed: return 134;
0
30 case
never executed: case 0000005 :
never executed: case 0000005 :
0
31 0000005
never executed: case 0000005 :
0
32 :
never executed: case 0000005 :
0
33 return
never executed: return 150;
150;
never executed: return 150;
0
34 case
never executed: case 0000006 :
never executed: case 0000006 :
0
35 0000006
never executed: case 0000006 :
0
36 :
never executed: case 0000006 :
0
37 return
never executed: return 200;
200;
never executed: return 200;
0
38 case
never executed: case 0000007 :
never executed: case 0000007 :
0
39 0000007
never executed: case 0000007 :
0
40 :
never executed: case 0000007 :
0
41 return
never executed: return 300;
300;
never executed: return 300;
0
42 case
never executed: case 0000010 :
never executed: case 0000010 :
0
43 0000010
never executed: case 0000010 :
0
44 :
never executed: case 0000010 :
0
45 return
never executed: return 600;
600;
never executed: return 600;
0
46 case
never executed: case 0000011 :
never executed: case 0000011 :
0
47 0000011
never executed: case 0000011 :
0
48 :
never executed: case 0000011 :
0
49 return
never executed: return 1200;
1200;
never executed: return 1200;
0
50 case
never executed: case 0000012 :
never executed: case 0000012 :
0
51 0000012
never executed: case 0000012 :
0
52 :
never executed: case 0000012 :
0
53 return
never executed: return 1800;
1800;
never executed: return 1800;
0
54 case
never executed: case 0000013 :
never executed: case 0000013 :
0
55 0000013
never executed: case 0000013 :
0
56 :
never executed: case 0000013 :
0
57 return
never executed: return 2400;
2400;
never executed: return 2400;
0
58 case
never executed: case 0000014 :
never executed: case 0000014 :
0
59 0000014
never executed: case 0000014 :
0
60 :
never executed: case 0000014 :
0
61 return
never executed: return 4800;
4800;
never executed: return 4800;
0
62 case
never executed: case 0000015 :
never executed: case 0000015 :
0
63 0000015
never executed: case 0000015 :
0
64 :
never executed: case 0000015 :
0
65 return
never executed: return 9600;
9600;
never executed: return 9600;
0
66-
67-
68 case
never executed: case 0000016 :
never executed: case 0000016 :
0
69 0000016
never executed: case 0000016 :
0
70 :
never executed: case 0000016 :
0
71 return
never executed: return 19200;
19200;
never executed: return 19200;
0
72 case
never executed: case 0000017 :
never executed: case 0000017 :
0
73 0000017
never executed: case 0000017 :
0
74 :
never executed: case 0000017 :
0
75 return
never executed: return 38400;
38400;
never executed: return 38400;
0
76 case
never executed: case 0010001 :
never executed: case 0010001 :
0
77 0010001
never executed: case 0010001 :
0
78 :
never executed: case 0010001 :
0
79 return
never executed: return 57600;
57600;
never executed: return 57600;
0
80-
81-
82-
83-
84-
85-
86 case
never executed: case 0010002 :
never executed: case 0010002 :
0
87 0010002
never executed: case 0010002 :
0
88 :
never executed: case 0010002 :
0
89 return
never executed: return 115200;
115200;
never executed: return 115200;
0
90-
91-
92 case
never executed: case 0010003 :
never executed: case 0010003 :
0
93 0010003
never executed: case 0010003 :
0
94 :
never executed: case 0010003 :
0
95 return
never executed: return 230400;
230400;
never executed: return 230400;
0
96-
97 default
never executed: default:
:
never executed: default:
0
98 return
never executed: return 9600;
9600;
never executed: return 9600;
0
99 }-
100}-
101-
102-
103-
104-
105static speed_t-
106baud_to_speed(int baud)-
107{-
108 switch (baud) {-
109 case
never executed: case 0:
0:
never executed: case 0:
0
110 return
never executed: return 0000000 ;
never executed: return 0000000 ;
0
111 0000000
never executed: return 0000000 ;
0
112 ;
never executed: return 0000000 ;
0
113 case
never executed: case 50:
50:
never executed: case 50:
0
114 return
never executed: return 0000001 ;
never executed: return 0000001 ;
0
115 0000001
never executed: return 0000001 ;
0
116 ;
never executed: return 0000001 ;
0
117 case
never executed: case 75:
75:
never executed: case 75:
0
118 return
never executed: return 0000002 ;
never executed: return 0000002 ;
0
119 0000002
never executed: return 0000002 ;
0
120 ;
never executed: return 0000002 ;
0
121 case
never executed: case 110:
110:
never executed: case 110:
0
122 return
never executed: return 0000003 ;
never executed: return 0000003 ;
0
123 0000003
never executed: return 0000003 ;
0
124 ;
never executed: return 0000003 ;
0
125 case
never executed: case 134:
134:
never executed: case 134:
0
126 return
never executed: return 0000004 ;
never executed: return 0000004 ;
0
127 0000004
never executed: return 0000004 ;
0
128 ;
never executed: return 0000004 ;
0
129 case
never executed: case 150:
150:
never executed: case 150:
0
130 return
never executed: return 0000005 ;
never executed: return 0000005 ;
0
131 0000005
never executed: return 0000005 ;
0
132 ;
never executed: return 0000005 ;
0
133 case
never executed: case 200:
200:
never executed: case 200:
0
134 return
never executed: return 0000006 ;
never executed: return 0000006 ;
0
135 0000006
never executed: return 0000006 ;
0
136 ;
never executed: return 0000006 ;
0
137 case
never executed: case 300:
300:
never executed: case 300:
0
138 return
never executed: return 0000007 ;
never executed: return 0000007 ;
0
139 0000007
never executed: return 0000007 ;
0
140 ;
never executed: return 0000007 ;
0
141 case
never executed: case 600:
600:
never executed: case 600:
0
142 return
never executed: return 0000010 ;
never executed: return 0000010 ;
0
143 0000010
never executed: return 0000010 ;
0
144 ;
never executed: return 0000010 ;
0
145 case
never executed: case 1200:
1200:
never executed: case 1200:
0
146 return
never executed: return 0000011 ;
never executed: return 0000011 ;
0
147 0000011
never executed: return 0000011 ;
0
148 ;
never executed: return 0000011 ;
0
149 case
never executed: case 1800:
1800:
never executed: case 1800:
0
150 return
never executed: return 0000012 ;
never executed: return 0000012 ;
0
151 0000012
never executed: return 0000012 ;
0
152 ;
never executed: return 0000012 ;
0
153 case
never executed: case 2400:
2400:
never executed: case 2400:
0
154 return
never executed: return 0000013 ;
never executed: return 0000013 ;
0
155 0000013
never executed: return 0000013 ;
0
156 ;
never executed: return 0000013 ;
0
157 case
never executed: case 4800:
4800:
never executed: case 4800:
0
158 return
never executed: return 0000014 ;
never executed: return 0000014 ;
0
159 0000014
never executed: return 0000014 ;
0
160 ;
never executed: return 0000014 ;
0
161 case
never executed: case 9600:
9600:
never executed: case 9600:
0
162 return
never executed: return 0000015 ;
never executed: return 0000015 ;
0
163 0000015
never executed: return 0000015 ;
0
164 ;
never executed: return 0000015 ;
0
165-
166-
167 case
never executed: case 19200:
19200:
never executed: case 19200:
0
168 return
never executed: return 0000016 ;
never executed: return 0000016 ;
0
169 0000016
never executed: return 0000016 ;
0
170 ;
never executed: return 0000016 ;
0
171 case
never executed: case 38400:
38400:
never executed: case 38400:
0
172 return
never executed: return 0000017 ;
never executed: return 0000017 ;
0
173 0000017
never executed: return 0000017 ;
0
174 ;
never executed: return 0000017 ;
0
175 case
never executed: case 57600:
57600:
never executed: case 57600:
0
176 return
never executed: return 0010001 ;
never executed: return 0010001 ;
0
177 0010001
never executed: return 0010001 ;
0
178 ;
never executed: return 0010001 ;
0
179-
180-
181-
182-
183-
184-
185 case
never executed: case 115200:
115200:
never executed: case 115200:
0
186 return
never executed: return 0010002 ;
never executed: return 0010002 ;
0
187 0010002
never executed: return 0010002 ;
0
188 ;
never executed: return 0010002 ;
0
189-
190-
191 case
never executed: case 230400:
230400:
never executed: case 230400:
0
192 return
never executed: return 0010003 ;
never executed: return 0010003 ;
0
193 0010003
never executed: return 0010003 ;
0
194 ;
never executed: return 0010003 ;
0
195-
196 default
never executed: default:
:
never executed: default:
0
197 return
never executed: return 0000015 ;
never executed: return 0000015 ;
0
198 0000015
never executed: return 0000015 ;
0
199 ;
never executed: return 0000015 ;
0
200 }-
201}-
202-
203-
204-
205-
206static u_int-
207special_char_encode(cc_t c)-
208{-
209-
210-
211-
212-
213 return
never executed: return c;
c;
never executed: return c;
0
214}-
215-
216-
217-
218-
219static cc_t-
220special_char_decode(u_int c)-
221{-
222-
223-
224-
225-
226 return
never executed: return c;
c;
never executed: return c;
0
227}-
228-
229-
230-
231-
232-
233-
234void-
235ssh_tty_make_modes(struct ssh *ssh, int fd, struct termios *tiop)-
236{-
237 struct termios tio;-
238 struct sshbuf *buf;-
239 int r, ibaud, obaud;-
240-
241 if ((
(buf = sshbuf_...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
buf = sshbuf_new()) ==
(buf = sshbuf_...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
242 ((void *)0)
(buf = sshbuf_...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
243 )-
244 fatal("%s: sshbuf_new failed", __func__);
never executed: fatal("%s: sshbuf_new failed", __func__);
0
245-
246 if (tiop ==
tiop == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
247 ((void *)0)
tiop == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
248 ) {-
249 if (fd == -1
fd == -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
250 debug("%s: no fd or tio", __func__);-
251 goto
never executed: goto end;
end;
never executed: goto end;
0
252 }-
253 if (tcgetattr(fd, &tio) == -1
tcgetattr(fd, &tio) == -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
254 logit("tcgetattr: %.100s", strerror(-
255 (*__errno_location ())-
256 ));-
257 goto
never executed: goto end;
end;
never executed: goto end;
0
258 }-
259 }
never executed: end of block
else
0
260 tio = *tiop;
never executed: tio = *tiop;
0
261-
262-
263 obaud = speed_to_baud(cfgetospeed(&tio));-
264 ibaud = speed_to_baud(cfgetispeed(&tio));-
265 if ((
(r = sshbuf_pu...uf, 129)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
r = sshbuf_put_u8(buf, 129)) != 0
(r = sshbuf_pu...uf, 129)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
||
0
266 (
(r = sshbuf_pu..., obaud)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
r = sshbuf_put_u32(buf, obaud)) != 0
(r = sshbuf_pu..., obaud)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
||
0
267 (
(r = sshbuf_pu...uf, 128)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
r = sshbuf_put_u8(buf, 128)) != 0
(r = sshbuf_pu...uf, 128)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
||
0
268 (
(r = sshbuf_pu..., ibaud)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
r = sshbuf_put_u32(buf, ibaud)) != 0
(r = sshbuf_pu..., ibaud)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
269 fatal("%s: buffer error: %s", __func__, ssh_err(r));
never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r));
0
270-
271-
272-
273-
274end:
code before this statement never executed: end:
0
275-
276 if ((
(r = sshbuf_pu...(buf, 0)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
r = sshbuf_put_u8(buf, 0)) != 0
(r = sshbuf_pu...(buf, 0)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
||
0
277 (
(r = sshpkt_pu...sh, buf)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
r = sshpkt_put_stringb(ssh, buf)) != 0
(r = sshpkt_pu...sh, buf)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
278 fatal("%s: packet error: %s", __func__, ssh_err(r));
never executed: fatal("%s: packet error: %s", __func__, ssh_err(r));
0
279 sshbuf_free(buf);-
280}
never executed: end of block
0
281-
282-
283-
284-
285-
286void-
287ssh_tty_parse_modes(struct ssh *ssh, int fd)-
288{-
289 struct termios tio;-
290 struct sshbuf *buf;-
291 const u_char *data;-
292 u_char opcode;-
293 u_int baud, u;-
294 int r, failure = 0;-
295 size_t len;-
296-
297 if ((
(r = sshpkt_ge...a, &len)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
r = sshpkt_get_string_direct(ssh, &data, &len)) != 0
(r = sshpkt_ge...a, &len)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
298 fatal("%s: packet error: %s", __func__, ssh_err(r));
never executed: fatal("%s: packet error: %s", __func__, ssh_err(r));
0
299 if (len == 0
len == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
300 return;
never executed: return;
0
301 if ((
(buf = sshbuf_...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
buf = sshbuf_from(data, len)) ==
(buf = sshbuf_...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
302 ((void *)0)
(buf = sshbuf_...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
303 ) {-
304 error("%s: sshbuf_from failed", __func__);-
305 return;
never executed: return;
0
306 }-
307-
308-
309-
310-
311-
312-
313 if (tcgetattr(fd, &tio) == -1
tcgetattr(fd, &tio) == -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
314 logit("tcgetattr: %.100s", strerror(-
315 (*__errno_location ())-
316 ));-
317 failure = -1;-
318 }
never executed: end of block
0
319-
320 while (sshbuf_len(buf) > 0
sshbuf_len(buf) > 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
321 if ((
(r = sshbuf_ge...&opcode)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
r = sshbuf_get_u8(buf, &opcode)) != 0
(r = sshbuf_ge...&opcode)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
322 fatal("%s: packet error: %s", __func__, ssh_err(r));
never executed: fatal("%s: packet error: %s", __func__, ssh_err(r));
0
323 switch (opcode) {-
324 case
never executed: case 0:
0:
never executed: case 0:
0
325 goto
never executed: goto set;
set;
never executed: goto set;
0
326-
327 case
never executed: case 128:
128:
never executed: case 128:
0
328 if ((
(r = sshbuf_ge..., &baud)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
r = sshbuf_get_u32(buf, &baud)) != 0
(r = sshbuf_ge..., &baud)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
329 fatal("%s: packet error: %s",
never executed: fatal("%s: packet error: %s", __func__, ssh_err(r));
0
330 __func__, ssh_err(r));
never executed: fatal("%s: packet error: %s", __func__, ssh_err(r));
0
331 if (failure != -1
failure != -1Description
TRUEnever evaluated
FALSEnever evaluated
&&
0
332 cfsetispeed(&tio, baud_to_speed(baud)) == -1
cfsetispeed(&t...d(baud)) == -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
333 error("cfsetispeed failed for %d", baud);
never executed: error("cfsetispeed failed for %d", baud);
0
334 break;
never executed: break;
0
335-
336 case
never executed: case 129:
129:
never executed: case 129:
0
337 if ((
(r = sshbuf_ge..., &baud)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
r = sshbuf_get_u32(buf, &baud)) != 0
(r = sshbuf_ge..., &baud)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
338 fatal("%s: packet error: %s",
never executed: fatal("%s: packet error: %s", __func__, ssh_err(r));
0
339 __func__, ssh_err(r));
never executed: fatal("%s: packet error: %s", __func__, ssh_err(r));
0
340 if (failure != -1
failure != -1Description
TRUEnever evaluated
FALSEnever evaluated
&&
0
341 cfsetospeed(&tio, baud_to_speed(baud)) == -1
cfsetospeed(&t...d(baud)) == -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
342 error("cfsetospeed failed for %d", baud);
never executed: error("cfsetospeed failed for %d", baud);
0
343 break;
never executed: break;
0
344-
345-
346-
347-
348 default
never executed: default:
:
never executed: default:
0
349 debug("Ignoring unsupported tty mode opcode %d (0x%x)",-
350 opcode, opcode);-
351-
352-
353-
354-
355-
356-
357-
358 if (opcode > 0
opcode > 0Description
TRUEnever evaluated
FALSEnever evaluated
&& opcode < 160
opcode < 160Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
359 if ((
(r = sshbuf_ge...d *)0) )) != 0Description
TRUEnever evaluated
FALSEnever evaluated
r = sshbuf_get_u32(buf,
(r = sshbuf_ge...d *)0) )) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
360 ((void *)0)
(r = sshbuf_ge...d *)0) )) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
361 )) != 0
(r = sshbuf_ge...d *)0) )) != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
362 fatal("%s: packet error: %s", __func__,
never executed: fatal("%s: packet error: %s", __func__, ssh_err(r));
0
363 ssh_err(r));
never executed: fatal("%s: packet error: %s", __func__, ssh_err(r));
0
364 break;
never executed: break;
0
365 } else {-
366 logit("%s: unknown opcode %d", __func__,-
367 opcode);-
368 goto
never executed: goto set;
set;
never executed: goto set;
0
369 }-
370 }-
371 }-
372-
373set:
code before this statement never executed: set:
0
374 len = sshbuf_len(buf);-
375 sshbuf_free(buf);-
376 if (len > 0
len > 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
377 logit("%s: %zu bytes left", __func__, len);-
378 return;
never executed: return;
0
379 }-
380 if (failure == -1
failure == -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
381 return;
never executed: return;
0
382-
383-
384 if (tcsetattr(fd,
tcsetattr(fd, 0 , &tio) == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
385 0
tcsetattr(fd, 0 , &tio) == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
386 , &tio) == -1
tcsetattr(fd, 0 , &tio) == -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
387 logit("Setting tty modes failed: %.100s", strerror(
never executed: logit("Setting tty modes failed: %.100s", strerror( (*__errno_location ()) ));
0
388 (*__errno_location ())
never executed: logit("Setting tty modes failed: %.100s", strerror( (*__errno_location ()) ));
0
389 ));
never executed: logit("Setting tty modes failed: %.100s", strerror( (*__errno_location ()) ));
0
390}
never executed: end of block
0
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2