aboutsummaryrefslogtreecommitdiff
path: root/src/packet_cb.c
diff options
context:
space:
mode:
authorJon Simons <jon@jonsimons.org>2014-02-10 17:43:54 -0800
committerAndreas Schneider <asn@cryptomilk.org>2014-03-12 14:11:09 +0100
commit0bb779904d81db4ff55d969a060955496e9e4ed5 (patch)
tree20c205aae8d6bd65e068e030c09e8cf67bb9d07c /src/packet_cb.c
parent5eeac3566e11874ad62337a702fef84c8ef29d87 (diff)
downloadlibssh-0bb779904d81db4ff55d969a060955496e9e4ed5.tar.gz
libssh-0bb779904d81db4ff55d969a060955496e9e4ed5.tar.xz
libssh-0bb779904d81db4ff55d969a060955496e9e4ed5.zip
packet: log disconnect code in host byte order
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'src/packet_cb.c')
-rw-r--r--src/packet_cb.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/packet_cb.c b/src/packet_cb.c
index f5d4f055..a10dd1ab 100644
--- a/src/packet_cb.c
+++ b/src/packet_cb.c
@@ -43,29 +43,35 @@
* @brief Handle a SSH_DISCONNECT packet.
*/
SSH_PACKET_CALLBACK(ssh_packet_disconnect_callback){
- uint32_t code;
- char *error=NULL;
- ssh_string error_s;
- (void)user;
- (void)type;
- buffer_get_u32(packet, &code);
+ int rc;
+ uint32_t code = 0;
+ char *error = NULL;
+ ssh_string error_s;
+ (void)user;
+ (void)type;
+
+ rc = buffer_get_u32(packet, &code);
+ if (rc != 0) {
+ code = ntohl(code);
+ }
+
error_s = buffer_get_ssh_string(packet);
if (error_s != NULL) {
error = ssh_string_to_char(error_s);
ssh_string_free(error_s);
}
- SSH_LOG(SSH_LOG_PACKET, "Received SSH_MSG_DISCONNECT %d:%s",code,
- error != NULL ? error : "no error");
+ SSH_LOG(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");
+ "Received SSH_MSG_DISCONNECT: %d:%s",
+ code, error != NULL ? error : "no error");
SAFE_FREE(error);
ssh_socket_close(session->socket);
session->alive = 0;
- session->session_state= SSH_SESSION_STATE_ERROR;
- /* TODO: handle a graceful disconnect */
- return SSH_PACKET_USED;
+ session->session_state = SSH_SESSION_STATE_ERROR;
+ /* TODO: handle a graceful disconnect */
+ return SSH_PACKET_USED;
}
/**