summaryrefslogtreecommitdiffstats
path: root/libssh/session.c
diff options
context:
space:
mode:
Diffstat (limited to 'libssh/session.c')
-rw-r--r--libssh/session.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/libssh/session.c b/libssh/session.c
index c03553c..adb4191 100644
--- a/libssh/session.c
+++ b/libssh/session.c
@@ -366,23 +366,25 @@ int ssh_get_version(ssh_session session) {
*/
SSH_PACKET_CALLBACK(ssh_packet_disconnect_callback){
uint32_t code;
- char *error;
+ char *error=NULL;
ssh_string error_s;
(void)user;
(void)type;
- buffer_get_u32(packet, &code);
- error_s = buffer_get_ssh_string(packet);
- if (error_s != NULL) {
- error = string_to_char(error_s);
- string_free(error_s);
- }
- ssh_log(session, SSH_LOG_PACKET, "Received SSH_MSG_DISCONNECT %d:%s",code,error);
- ssh_set_error(session, SSH_FATAL,
- "Received SSH_MSG_DISCONNECT: %d:%s",code,error);
- SAFE_FREE(error);
+ buffer_get_u32(packet, &code);
+ error_s = buffer_get_ssh_string(packet);
+ if (error_s != NULL) {
+ error = string_to_char(error_s);
+ string_free(error_s);
+ }
+ ssh_log(session, SSH_LOG_PACKET, "Received SSH_MSG_DISCONNECT %d:%s",code,
+ error != NULL ? error : "no error");
+ ssh_set_error(session, SSH_FATAL,
+ "Received SSH_MSG_DISCONNECT: %d:%s",code,
+ error != NULL ? error : "no error");
+ SAFE_FREE(error);
- ssh_socket_close(session->socket);
- session->alive = 0;
+ ssh_socket_close(session->socket);
+ session->alive = 0;
/* TODO: handle a graceful disconnect */
return SSH_PACKET_USED;
}