diff options
author | djm@openbsd.org <djm@openbsd.org> | 2015-01-30 01:13:33 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2015-01-30 12:18:59 +1100 |
commit | 4509b5d4a4fa645a022635bfa7e86d09b285001f (patch) | |
tree | cb94ac37e4d5c59a3a5c2cde3b6c76363e7035d3 /opacket.c | |
parent | 669aee994348468af8b4b2ebd29b602cf2860b22 (diff) |
upstream commit
avoid more fatal/exit in the packet.c paths that
ssh-keyscan uses; feedback and "looks good" markus@
Diffstat (limited to 'opacket.c')
-rw-r--r-- | opacket.c | 49 |
1 files changed, 33 insertions, 16 deletions
@@ -223,6 +223,8 @@ void | |||
223 | packet_set_connection(int fd_in, int fd_out) | 223 | packet_set_connection(int fd_in, int fd_out) |
224 | { | 224 | { |
225 | active_state = ssh_packet_set_connection(active_state, fd_in, fd_out); | 225 | active_state = ssh_packet_set_connection(active_state, fd_in, fd_out); |
226 | if (active_state == NULL) | ||
227 | fatal("%s: ssh_packet_set_connection failed", __func__); | ||
226 | } | 228 | } |
227 | 229 | ||
228 | void | 230 | void |
@@ -255,20 +257,8 @@ packet_read_seqnr(u_int32_t *seqnr) | |||
255 | u_char type; | 257 | u_char type; |
256 | int r; | 258 | int r; |
257 | 259 | ||
258 | if ((r = ssh_packet_read_seqnr(active_state, &type, seqnr)) != 0) { | 260 | if ((r = ssh_packet_read_seqnr(active_state, &type, seqnr)) != 0) |
259 | switch (r) { | 261 | sshpkt_fatal(active_state, __func__, r); |
260 | case SSH_ERR_CONN_CLOSED: | ||
261 | logit("Connection closed by %.200s", | ||
262 | ssh_remote_ipaddr(active_state)); | ||
263 | cleanup_exit(255); | ||
264 | case SSH_ERR_CONN_TIMEOUT: | ||
265 | logit("Connection to %.200s timed out while " | ||
266 | "waiting to read", ssh_remote_ipaddr(active_state)); | ||
267 | cleanup_exit(255); | ||
268 | default: | ||
269 | fatal("%s: %s", __func__, ssh_err(r)); | ||
270 | } | ||
271 | } | ||
272 | return type; | 262 | return type; |
273 | } | 263 | } |
274 | 264 | ||
@@ -279,7 +269,7 @@ packet_read_poll_seqnr(u_int32_t *seqnr) | |||
279 | int r; | 269 | int r; |
280 | 270 | ||
281 | if ((r = ssh_packet_read_poll_seqnr(active_state, &type, seqnr))) | 271 | if ((r = ssh_packet_read_poll_seqnr(active_state, &type, seqnr))) |
282 | fatal("%s: %s", __func__, ssh_err(r)); | 272 | sshpkt_fatal(active_state, __func__, r); |
283 | return type; | 273 | return type; |
284 | } | 274 | } |
285 | 275 | ||
@@ -296,5 +286,32 @@ packet_process_incoming(const char *buf, u_int len) | |||
296 | int r; | 286 | int r; |
297 | 287 | ||
298 | if ((r = ssh_packet_process_incoming(active_state, buf, len)) != 0) | 288 | if ((r = ssh_packet_process_incoming(active_state, buf, len)) != 0) |
299 | fatal("%s: %s", __func__, ssh_err(r)); | 289 | sshpkt_fatal(active_state, __func__, r); |
290 | } | ||
291 | |||
292 | void | ||
293 | packet_write_wait(void) | ||
294 | { | ||
295 | int r; | ||
296 | |||
297 | if ((r = ssh_packet_write_wait(active_state)) != 0) | ||
298 | sshpkt_fatal(active_state, __func__, r); | ||
299 | } | ||
300 | |||
301 | void | ||
302 | packet_write_poll(void) | ||
303 | { | ||
304 | int r; | ||
305 | |||
306 | if ((r = ssh_packet_write_poll(active_state)) != 0) | ||
307 | sshpkt_fatal(active_state, __func__, r); | ||
308 | } | ||
309 | |||
310 | void | ||
311 | packet_read_expect(int expected_type) | ||
312 | { | ||
313 | int r; | ||
314 | |||
315 | if ((r = ssh_packet_read_expect(active_state, expected_type)) != 0) | ||
316 | sshpkt_fatal(active_state, __func__, r); | ||
300 | } | 317 | } |