From 94f6c323ebd1f4124ee099f5ea108de606ef6d7c Mon Sep 17 00:00:00 2001 From: Yanis Kurganov Date: Thu, 9 Mar 2017 17:30:58 +0300 Subject: [PATCH] add ssh1 support for ssh_send_ignore & ssh_send_debug Signed-off-by: Yanis Kurganov --- src/session.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/src/session.c b/src/session.c index daafad2..5161d84 100644 --- a/src/session.c +++ b/src/session.c @@ -31,6 +31,9 @@ #include "libssh/crypto.h" #include "libssh/server.h" #include "libssh/socket.h" +#ifdef WITH_SSH1 +#include "libssh/ssh1.h" +#endif #include "libssh/ssh2.h" #include "libssh/agent.h" #include "libssh/packet.h" @@ -831,13 +834,17 @@ void ssh_socket_exception_callback(int code, int errno_code, void *user){ * @return SSH_OK on success, SSH_ERROR otherwise. */ int ssh_send_ignore (ssh_session session, const char *data) { +#ifdef WITH_SSH1 + const int type = session->version == 1 ? SSH_MSG_IGNORE : SSH2_MSG_IGNORE; +#else + const int type = SSH2_MSG_IGNORE; +#endif int rc; if (ssh_socket_is_open(session->socket)) { - rc = ssh_buffer_pack(session->out_buffer, "bs", - SSH2_MSG_IGNORE, + type, data); if (rc != SSH_OK){ ssh_set_error_oom(session); @@ -846,7 +853,6 @@ int ssh_send_ignore (ssh_session session, const char *data) { packet_send(session); ssh_handle_packets(session, 0); } - return SSH_OK; error: @@ -869,12 +875,22 @@ int ssh_send_debug (ssh_session session, const char *message, int always_display int rc; if (ssh_socket_is_open(session->socket)) { - rc = ssh_buffer_pack(session->out_buffer, - "bbsd", - SSH2_MSG_DEBUG, - always_display != 0 ? 1 : 0, - message, - 0); /* empty language tag */ +#ifdef WITH_SSH1 + if (session->version == 1) { + rc = ssh_buffer_pack(session->out_buffer, + "bs", + SSH_MSG_DEBUG, + message); + } else +#endif + { + rc = ssh_buffer_pack(session->out_buffer, + "bbsd", + SSH2_MSG_DEBUG, + always_display != 0 ? 1 : 0, + message, + 0); /* empty language tag */ + } if (rc != SSH_OK) { ssh_set_error_oom(session); goto error; @@ -882,7 +898,6 @@ int ssh_send_debug (ssh_session session, const char *message, int always_display packet_send(session); ssh_handle_packets(session, 0); } - return SSH_OK; error: -- 1.9.5.msysgit.0