version 1.279, 2019/01/04 03:23:00 |
version 1.280, 2019/01/19 21:33:14 |
|
|
/* |
/* |
* Pretty-print connection-terminating errors and exit. |
* Pretty-print connection-terminating errors and exit. |
*/ |
*/ |
void |
static void |
sshpkt_fatal(struct ssh *ssh, const char *tag, int r) |
sshpkt_vfatal(struct ssh *ssh, int r, const char *fmt, va_list ap) |
{ |
{ |
char remote_id[512]; |
char *tag = NULL, remote_id[512]; |
|
|
sshpkt_fmt_connection_id(ssh, remote_id, sizeof(remote_id)); |
sshpkt_fmt_connection_id(ssh, remote_id, sizeof(remote_id)); |
|
|
|
|
} |
} |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
default: |
default: |
|
if (vasprintf(&tag, fmt, ap) == -1) { |
|
ssh_packet_clear_keys(ssh); |
|
logdie("%s: could not allocate failure message", |
|
__func__); |
|
} |
ssh_packet_clear_keys(ssh); |
ssh_packet_clear_keys(ssh); |
logdie("%s%sConnection %s %s: %s", |
logdie("%s%sConnection %s %s: %s", |
tag != NULL ? tag : "", tag != NULL ? ": " : "", |
tag != NULL ? tag : "", tag != NULL ? ": " : "", |
|
|
} |
} |
} |
} |
|
|
|
void |
|
sshpkt_fatal(struct ssh *ssh, int r, const char *fmt, ...) |
|
{ |
|
va_list ap; |
|
|
|
va_start(ap, fmt); |
|
sshpkt_vfatal(ssh, r, fmt, ap); |
|
/* NOTREACHED */ |
|
va_end(ap); |
|
logdie("%s: should have exited", __func__); |
|
} |
|
|
/* |
/* |
* Logs the error plus constructs and sends a disconnect packet, closes the |
* Logs the error plus constructs and sends a disconnect packet, closes the |
* connection, and exits. This function never returns. The error message |
* connection, and exits. This function never returns. The error message |
|
|
* for it to get sent. |
* for it to get sent. |
*/ |
*/ |
if ((r = sshpkt_disconnect(ssh, "%s", buf)) != 0) |
if ((r = sshpkt_disconnect(ssh, "%s", buf)) != 0) |
sshpkt_fatal(ssh, __func__, r); |
sshpkt_fatal(ssh, r, "%s", __func__); |
|
|
if ((r = ssh_packet_write_wait(ssh)) != 0) |
if ((r = ssh_packet_write_wait(ssh)) != 0) |
sshpkt_fatal(ssh, __func__, r); |
sshpkt_fatal(ssh, r, "%s", __func__); |
|
|
/* Close the connection. */ |
/* Close the connection. */ |
ssh_packet_close(ssh); |
ssh_packet_close(ssh); |