mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-08-08 19:02:06 +03:00
src: Remove enter_function() and leave_function().
This commit is contained in:
182
src/channels.c
182
src/channels.c
@@ -143,7 +143,7 @@ SSH_PACKET_CALLBACK(ssh_packet_channel_open_conf){
|
||||
ssh_channel channel;
|
||||
(void)type;
|
||||
(void)user;
|
||||
enter_function();
|
||||
|
||||
SSH_LOG(SSH_LOG_PACKET,"Received SSH2_MSG_CHANNEL_OPEN_CONFIRMATION");
|
||||
|
||||
buffer_get_u32(packet, &channelid);
|
||||
@@ -154,7 +154,7 @@ SSH_PACKET_CALLBACK(ssh_packet_channel_open_conf){
|
||||
"Unknown channel id %lu",
|
||||
(long unsigned int) channelid);
|
||||
/* TODO: Set error marking in channel object */
|
||||
leave_function();
|
||||
|
||||
return SSH_PACKET_USED;
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ SSH_PACKET_CALLBACK(ssh_packet_channel_open_conf){
|
||||
|
||||
channel->state = SSH_CHANNEL_STATE_OPEN;
|
||||
channel->flags = channel->flags & ~SSH_CHANNEL_FLAG_NOT_BOUND;
|
||||
leave_function();
|
||||
|
||||
return SSH_PACKET_USED;
|
||||
}
|
||||
|
||||
@@ -254,7 +254,6 @@ static int channel_open(ssh_channel channel, const char *type_c, int window,
|
||||
ssh_string type = NULL;
|
||||
int err=SSH_ERROR;
|
||||
|
||||
enter_function();
|
||||
switch(channel->state){
|
||||
case SSH_CHANNEL_STATE_NOT_OPEN:
|
||||
break;
|
||||
@@ -278,7 +277,7 @@ static int channel_open(ssh_channel channel, const char *type_c, int window,
|
||||
type = ssh_string_from_char(type_c);
|
||||
if (type == NULL) {
|
||||
ssh_set_error_oom(session);
|
||||
leave_function();
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -289,7 +288,7 @@ static int channel_open(ssh_channel channel, const char *type_c, int window,
|
||||
buffer_add_u32(session->out_buffer, htonl(channel->local_maxpacket)) < 0) {
|
||||
ssh_set_error_oom(session);
|
||||
ssh_string_free(type);
|
||||
leave_function();
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -298,13 +297,13 @@ static int channel_open(ssh_channel channel, const char *type_c, int window,
|
||||
if (payload != NULL) {
|
||||
if (buffer_add_buffer(session->out_buffer, payload) < 0) {
|
||||
ssh_set_error_oom(session);
|
||||
leave_function();
|
||||
|
||||
return err;
|
||||
}
|
||||
}
|
||||
channel->state = SSH_CHANNEL_STATE_OPENING;
|
||||
if (packet_send(session) == SSH_ERROR) {
|
||||
leave_function();
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -319,7 +318,7 @@ pending:
|
||||
end:
|
||||
if(channel->state == SSH_CHANNEL_STATE_OPEN)
|
||||
err=SSH_OK;
|
||||
leave_function();
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -351,11 +350,10 @@ ssh_channel ssh_channel_from_local(ssh_session session, uint32_t id) {
|
||||
static int grow_window(ssh_session session, ssh_channel channel, int minimumsize) {
|
||||
uint32_t new_window = minimumsize > WINDOWBASE ? minimumsize : WINDOWBASE;
|
||||
|
||||
enter_function();
|
||||
#ifdef WITH_SSH1
|
||||
if (session->version == 1){
|
||||
channel->remote_window = new_window;
|
||||
leave_function();
|
||||
|
||||
return SSH_OK;
|
||||
}
|
||||
#endif
|
||||
@@ -364,7 +362,7 @@ static int grow_window(ssh_session session, ssh_channel channel, int minimumsize
|
||||
"growing window (channel %d:%d) to %d bytes : not needed (%d bytes)",
|
||||
channel->local_channel, channel->remote_channel, new_window,
|
||||
channel->local_window);
|
||||
leave_function();
|
||||
|
||||
return SSH_OK;
|
||||
}
|
||||
/* WINDOW_ADJUST packet needs a relative increment rather than an absolute
|
||||
@@ -389,12 +387,10 @@ static int grow_window(ssh_session session, ssh_channel channel, int minimumsize
|
||||
|
||||
channel->local_window = new_window;
|
||||
|
||||
leave_function();
|
||||
return SSH_OK;
|
||||
error:
|
||||
buffer_reinit(session->out_buffer);
|
||||
|
||||
leave_function();
|
||||
return SSH_ERROR;
|
||||
}
|
||||
|
||||
@@ -443,7 +439,6 @@ SSH_PACKET_CALLBACK(channel_rcv_change_window) {
|
||||
int rc;
|
||||
(void)user;
|
||||
(void)type;
|
||||
enter_function();
|
||||
|
||||
channel = channel_from_msg(session,packet);
|
||||
if (channel == NULL) {
|
||||
@@ -454,7 +449,7 @@ SSH_PACKET_CALLBACK(channel_rcv_change_window) {
|
||||
if (channel == NULL || rc != sizeof(uint32_t)) {
|
||||
SSH_LOG(SSH_LOG_PACKET,
|
||||
"Error getting a window adjust message: invalid packet");
|
||||
leave_function();
|
||||
|
||||
return SSH_PACKET_USED;
|
||||
}
|
||||
|
||||
@@ -468,7 +463,6 @@ SSH_PACKET_CALLBACK(channel_rcv_change_window) {
|
||||
|
||||
channel->remote_window += bytes;
|
||||
|
||||
leave_function();
|
||||
return SSH_PACKET_USED;
|
||||
}
|
||||
|
||||
@@ -481,7 +475,7 @@ SSH_PACKET_CALLBACK(channel_rcv_data){
|
||||
int is_stderr;
|
||||
int rest;
|
||||
(void)user;
|
||||
enter_function();
|
||||
|
||||
if(type==SSH2_MSG_CHANNEL_DATA)
|
||||
is_stderr=0;
|
||||
else
|
||||
@@ -491,7 +485,7 @@ SSH_PACKET_CALLBACK(channel_rcv_data){
|
||||
if (channel == NULL) {
|
||||
SSH_LOG(SSH_LOG_FUNCTIONS,
|
||||
"%s", ssh_get_error(session));
|
||||
leave_function();
|
||||
|
||||
return SSH_PACKET_USED;
|
||||
}
|
||||
|
||||
@@ -504,7 +498,7 @@ SSH_PACKET_CALLBACK(channel_rcv_data){
|
||||
str = buffer_get_ssh_string(packet);
|
||||
if (str == NULL) {
|
||||
SSH_LOG(SSH_LOG_PACKET, "Invalid data packet!");
|
||||
leave_function();
|
||||
|
||||
return SSH_PACKET_USED;
|
||||
}
|
||||
len = ssh_string_len(str);
|
||||
@@ -527,7 +521,7 @@ SSH_PACKET_CALLBACK(channel_rcv_data){
|
||||
if (channel_default_bufferize(channel, ssh_string_data(str), len,
|
||||
is_stderr) < 0) {
|
||||
ssh_string_free(str);
|
||||
leave_function();
|
||||
|
||||
return SSH_PACKET_USED;
|
||||
}
|
||||
|
||||
@@ -561,13 +555,11 @@ SSH_PACKET_CALLBACK(channel_rcv_data){
|
||||
}
|
||||
if (channel->local_window + buffer_get_rest_len(buf) < WINDOWLIMIT) {
|
||||
if (grow_window(session, channel, 0) < 0) {
|
||||
leave_function();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
leave_function();
|
||||
return SSH_PACKET_USED;
|
||||
}
|
||||
|
||||
@@ -575,12 +567,11 @@ SSH_PACKET_CALLBACK(channel_rcv_eof) {
|
||||
ssh_channel channel;
|
||||
(void)user;
|
||||
(void)type;
|
||||
enter_function();
|
||||
|
||||
channel = channel_from_msg(session,packet);
|
||||
if (channel == NULL) {
|
||||
SSH_LOG(SSH_LOG_FUNCTIONS, "%s", ssh_get_error(session));
|
||||
leave_function();
|
||||
|
||||
return SSH_PACKET_USED;
|
||||
}
|
||||
|
||||
@@ -597,7 +588,6 @@ SSH_PACKET_CALLBACK(channel_rcv_eof) {
|
||||
channel->callbacks->userdata);
|
||||
}
|
||||
|
||||
leave_function();
|
||||
return SSH_PACKET_USED;
|
||||
}
|
||||
|
||||
@@ -605,12 +595,11 @@ SSH_PACKET_CALLBACK(channel_rcv_close) {
|
||||
ssh_channel channel;
|
||||
(void)user;
|
||||
(void)type;
|
||||
enter_function();
|
||||
|
||||
channel = channel_from_msg(session,packet);
|
||||
if (channel == NULL) {
|
||||
SSH_LOG(SSH_LOG_FUNCTIONS, "%s", ssh_get_error(session));
|
||||
leave_function();
|
||||
|
||||
return SSH_PACKET_USED;
|
||||
}
|
||||
|
||||
@@ -645,7 +634,7 @@ SSH_PACKET_CALLBACK(channel_rcv_close) {
|
||||
channel->flags &= SSH_CHANNEL_FLAG_CLOSED_REMOTE;
|
||||
if(channel->flags & SSH_CHANNEL_FLAG_FREED_LOCAL)
|
||||
ssh_channel_do_free(channel);
|
||||
leave_function();
|
||||
|
||||
return SSH_PACKET_USED;
|
||||
}
|
||||
|
||||
@@ -658,26 +647,24 @@ SSH_PACKET_CALLBACK(channel_rcv_request) {
|
||||
(void)user;
|
||||
(void)type;
|
||||
|
||||
enter_function();
|
||||
|
||||
channel = channel_from_msg(session,packet);
|
||||
if (channel == NULL) {
|
||||
SSH_LOG(SSH_LOG_FUNCTIONS,"%s", ssh_get_error(session));
|
||||
leave_function();
|
||||
|
||||
return SSH_PACKET_USED;
|
||||
}
|
||||
|
||||
request_s = buffer_get_ssh_string(packet);
|
||||
if (request_s == NULL) {
|
||||
SSH_LOG(SSH_LOG_PACKET, "Invalid MSG_CHANNEL_REQUEST");
|
||||
leave_function();
|
||||
|
||||
return SSH_PACKET_USED;
|
||||
}
|
||||
|
||||
request = ssh_string_to_char(request_s);
|
||||
ssh_string_free(request_s);
|
||||
if (request == NULL) {
|
||||
leave_function();
|
||||
|
||||
return SSH_PACKET_USED;
|
||||
}
|
||||
|
||||
@@ -698,7 +685,6 @@ SSH_PACKET_CALLBACK(channel_rcv_request) {
|
||||
channel->callbacks->userdata);
|
||||
}
|
||||
|
||||
leave_function();
|
||||
return SSH_PACKET_USED;
|
||||
}
|
||||
|
||||
@@ -712,14 +698,14 @@ SSH_PACKET_CALLBACK(channel_rcv_request) {
|
||||
signal_str = buffer_get_ssh_string(packet);
|
||||
if (signal_str == NULL) {
|
||||
SSH_LOG(SSH_LOG_PACKET, "Invalid MSG_CHANNEL_REQUEST");
|
||||
leave_function();
|
||||
|
||||
return SSH_PACKET_USED;
|
||||
}
|
||||
|
||||
sig = ssh_string_to_char(signal_str);
|
||||
ssh_string_free(signal_str);
|
||||
if (sig == NULL) {
|
||||
leave_function();
|
||||
|
||||
return SSH_PACKET_USED;
|
||||
}
|
||||
|
||||
@@ -734,7 +720,6 @@ SSH_PACKET_CALLBACK(channel_rcv_request) {
|
||||
}
|
||||
SAFE_FREE(sig);
|
||||
|
||||
leave_function();
|
||||
return SSH_PACKET_USED;
|
||||
}
|
||||
|
||||
@@ -751,14 +736,14 @@ SSH_PACKET_CALLBACK(channel_rcv_request) {
|
||||
tmp = buffer_get_ssh_string(packet);
|
||||
if (tmp == NULL) {
|
||||
SSH_LOG(SSH_LOG_PACKET, "Invalid MSG_CHANNEL_REQUEST");
|
||||
leave_function();
|
||||
|
||||
return SSH_PACKET_USED;
|
||||
}
|
||||
|
||||
sig = ssh_string_to_char(tmp);
|
||||
ssh_string_free(tmp);
|
||||
if (sig == NULL) {
|
||||
leave_function();
|
||||
|
||||
return SSH_PACKET_USED;
|
||||
}
|
||||
|
||||
@@ -771,7 +756,7 @@ SSH_PACKET_CALLBACK(channel_rcv_request) {
|
||||
if (tmp == NULL) {
|
||||
SSH_LOG(SSH_LOG_PACKET, "Invalid MSG_CHANNEL_REQUEST");
|
||||
SAFE_FREE(sig);
|
||||
leave_function();
|
||||
|
||||
return SSH_PACKET_USED;
|
||||
}
|
||||
|
||||
@@ -779,7 +764,7 @@ SSH_PACKET_CALLBACK(channel_rcv_request) {
|
||||
ssh_string_free(tmp);
|
||||
if (errmsg == NULL) {
|
||||
SAFE_FREE(sig);
|
||||
leave_function();
|
||||
|
||||
return SSH_PACKET_USED;
|
||||
}
|
||||
|
||||
@@ -788,7 +773,7 @@ SSH_PACKET_CALLBACK(channel_rcv_request) {
|
||||
SSH_LOG(SSH_LOG_PACKET, "Invalid MSG_CHANNEL_REQUEST");
|
||||
SAFE_FREE(errmsg);
|
||||
SAFE_FREE(sig);
|
||||
leave_function();
|
||||
|
||||
return SSH_PACKET_USED;
|
||||
}
|
||||
|
||||
@@ -797,7 +782,7 @@ SSH_PACKET_CALLBACK(channel_rcv_request) {
|
||||
if (lang == NULL) {
|
||||
SAFE_FREE(errmsg);
|
||||
SAFE_FREE(sig);
|
||||
leave_function();
|
||||
|
||||
return SSH_PACKET_USED;
|
||||
}
|
||||
|
||||
@@ -814,7 +799,6 @@ SSH_PACKET_CALLBACK(channel_rcv_request) {
|
||||
SAFE_FREE(errmsg);
|
||||
SAFE_FREE(sig);
|
||||
|
||||
leave_function();
|
||||
return SSH_PACKET_USED;
|
||||
}
|
||||
if(strcmp(request,"keepalive@openssh.com")==0){
|
||||
@@ -829,7 +813,7 @@ SSH_PACKET_CALLBACK(channel_rcv_request) {
|
||||
return SSH_PACKET_USED;
|
||||
}
|
||||
packet_send(session);
|
||||
leave_function();
|
||||
|
||||
return SSH_PACKET_USED;
|
||||
}
|
||||
|
||||
@@ -840,7 +824,7 @@ SSH_PACKET_CALLBACK(channel_rcv_request) {
|
||||
channel->callbacks->channel_auth_agent_req_function(channel->session, channel,
|
||||
channel->callbacks->userdata);
|
||||
}
|
||||
leave_function();
|
||||
|
||||
return SSH_PACKET_USED;
|
||||
}
|
||||
#ifdef WITH_SERVER
|
||||
@@ -855,7 +839,6 @@ SSH_PACKET_CALLBACK(channel_rcv_request) {
|
||||
|
||||
SAFE_FREE(request);
|
||||
|
||||
leave_function();
|
||||
return SSH_PACKET_USED;
|
||||
}
|
||||
|
||||
@@ -1029,8 +1012,6 @@ int ssh_channel_open_forward(ssh_channel channel, const char *remotehost,
|
||||
return rc;
|
||||
}
|
||||
|
||||
enter_function();
|
||||
|
||||
payload = ssh_buffer_new();
|
||||
if (payload == NULL) {
|
||||
ssh_set_error_oom(session);
|
||||
@@ -1071,7 +1052,6 @@ error:
|
||||
ssh_buffer_free(payload);
|
||||
ssh_string_free(str);
|
||||
|
||||
leave_function();
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -1091,8 +1071,6 @@ void ssh_channel_free(ssh_channel channel) {
|
||||
}
|
||||
|
||||
session = channel->session;
|
||||
enter_function();
|
||||
|
||||
if (session->alive && channel->state == SSH_CHANNEL_STATE_OPEN) {
|
||||
ssh_channel_close(channel);
|
||||
}
|
||||
@@ -1107,7 +1085,6 @@ void ssh_channel_free(ssh_channel channel) {
|
||||
|| (channel->flags & SSH_CHANNEL_FLAG_NOT_BOUND)){
|
||||
ssh_channel_do_free(channel);
|
||||
}
|
||||
leave_function();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1151,7 +1128,6 @@ int ssh_channel_send_eof(ssh_channel channel){
|
||||
}
|
||||
|
||||
session = channel->session;
|
||||
enter_function();
|
||||
|
||||
if (buffer_add_u8(session->out_buffer, SSH2_MSG_CHANNEL_EOF) < 0) {
|
||||
ssh_set_error_oom(session);
|
||||
@@ -1169,12 +1145,10 @@ int ssh_channel_send_eof(ssh_channel channel){
|
||||
|
||||
channel->local_eof = 1;
|
||||
|
||||
leave_function();
|
||||
return rc;
|
||||
error:
|
||||
buffer_reinit(session->out_buffer);
|
||||
|
||||
leave_function();
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -1200,14 +1174,12 @@ int ssh_channel_close(ssh_channel channel){
|
||||
}
|
||||
|
||||
session = channel->session;
|
||||
enter_function();
|
||||
|
||||
if (channel->local_eof == 0) {
|
||||
rc = ssh_channel_send_eof(channel);
|
||||
}
|
||||
|
||||
if (rc != SSH_OK) {
|
||||
leave_function();
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -1227,12 +1199,10 @@ int ssh_channel_close(ssh_channel channel){
|
||||
channel->state=SSH_CHANNEL_STATE_CLOSED;
|
||||
}
|
||||
|
||||
leave_function();
|
||||
return rc;
|
||||
error:
|
||||
buffer_reinit(session->out_buffer);
|
||||
|
||||
leave_function();
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -1296,8 +1266,6 @@ int channel_write_common(ssh_channel channel, const void *data,
|
||||
return SSH_ERROR;
|
||||
}
|
||||
|
||||
enter_function();
|
||||
|
||||
/*
|
||||
* Handle the max packet len from remote side, be nice
|
||||
* 10 bytes for the headers
|
||||
@@ -1309,23 +1277,22 @@ int channel_write_common(ssh_channel channel, const void *data,
|
||||
"Can't write to channel %d:%d after EOF was sent",
|
||||
channel->local_channel,
|
||||
channel->remote_channel);
|
||||
leave_function();
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (channel->state != SSH_CHANNEL_STATE_OPEN || channel->delayed_close != 0) {
|
||||
ssh_set_error(session, SSH_REQUEST_DENIED, "Remote channel is closed");
|
||||
leave_function();
|
||||
|
||||
return -1;
|
||||
}
|
||||
if (channel->session->session_state == SSH_SESSION_STATE_ERROR){
|
||||
leave_function();
|
||||
|
||||
return SSH_ERROR;
|
||||
}
|
||||
#ifdef WITH_SSH1
|
||||
if (channel->version == 1) {
|
||||
rc = channel_write1(channel, data, len);
|
||||
leave_function();
|
||||
|
||||
return rc;
|
||||
}
|
||||
#endif
|
||||
@@ -1378,7 +1345,6 @@ int channel_write_common(ssh_channel channel, const void *data,
|
||||
}
|
||||
|
||||
if (packet_send(session) == SSH_ERROR) {
|
||||
leave_function();
|
||||
return SSH_ERROR;
|
||||
}
|
||||
|
||||
@@ -1394,13 +1360,11 @@ int channel_write_common(ssh_channel channel, const void *data,
|
||||
if(rc == SSH_ERROR)
|
||||
goto error;
|
||||
out:
|
||||
leave_function();
|
||||
return (int)(origlen - len);
|
||||
|
||||
error:
|
||||
buffer_reinit(session->out_buffer);
|
||||
|
||||
leave_function();
|
||||
return SSH_ERROR;
|
||||
}
|
||||
|
||||
@@ -1507,11 +1471,10 @@ SSH_PACKET_CALLBACK(ssh_packet_channel_success){
|
||||
ssh_channel channel;
|
||||
(void)type;
|
||||
(void)user;
|
||||
enter_function();
|
||||
|
||||
channel=channel_from_msg(session,packet);
|
||||
if (channel == NULL) {
|
||||
SSH_LOG(SSH_LOG_FUNCTIONS, "%s", ssh_get_error(session));
|
||||
leave_function();
|
||||
return SSH_PACKET_USED;
|
||||
}
|
||||
|
||||
@@ -1526,7 +1489,6 @@ SSH_PACKET_CALLBACK(ssh_packet_channel_success){
|
||||
channel->request_state=SSH_CHANNEL_REQ_STATE_ACCEPTED;
|
||||
}
|
||||
|
||||
leave_function();
|
||||
return SSH_PACKET_USED;
|
||||
}
|
||||
|
||||
@@ -1541,11 +1503,11 @@ SSH_PACKET_CALLBACK(ssh_packet_channel_failure){
|
||||
ssh_channel channel;
|
||||
(void)type;
|
||||
(void)user;
|
||||
enter_function();
|
||||
|
||||
channel=channel_from_msg(session,packet);
|
||||
if (channel == NULL) {
|
||||
SSH_LOG(SSH_LOG_FUNCTIONS, "%s", ssh_get_error(session));
|
||||
leave_function();
|
||||
|
||||
return SSH_PACKET_USED;
|
||||
}
|
||||
|
||||
@@ -1559,7 +1521,7 @@ SSH_PACKET_CALLBACK(ssh_packet_channel_failure){
|
||||
} else {
|
||||
channel->request_state=SSH_CHANNEL_REQ_STATE_DENIED;
|
||||
}
|
||||
leave_function();
|
||||
|
||||
return SSH_PACKET_USED;
|
||||
}
|
||||
|
||||
@@ -1578,7 +1540,6 @@ static int channel_request(ssh_channel channel, const char *request,
|
||||
ssh_string req = NULL;
|
||||
int rc = SSH_ERROR;
|
||||
|
||||
enter_function();
|
||||
switch(channel->request_state){
|
||||
case SSH_CHANNEL_REQ_STATE_NONE:
|
||||
break;
|
||||
@@ -1611,7 +1572,6 @@ static int channel_request(ssh_channel channel, const char *request,
|
||||
}
|
||||
channel->request_state = SSH_CHANNEL_REQ_STATE_PENDING;
|
||||
if (packet_send(session) == SSH_ERROR) {
|
||||
leave_function();
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -1619,7 +1579,6 @@ static int channel_request(ssh_channel channel, const char *request,
|
||||
"Sent a SSH_MSG_CHANNEL_REQUEST %s", request);
|
||||
if (reply == 0) {
|
||||
channel->request_state = SSH_CHANNEL_REQ_STATE_NONE;
|
||||
leave_function();
|
||||
return SSH_OK;
|
||||
}
|
||||
pending:
|
||||
@@ -1644,7 +1603,6 @@ pending:
|
||||
break;
|
||||
case SSH_CHANNEL_REQ_STATE_PENDING:
|
||||
rc = SSH_AGAIN;
|
||||
leave_function();
|
||||
return rc;
|
||||
case SSH_CHANNEL_REQ_STATE_NONE:
|
||||
/* Never reached */
|
||||
@@ -1653,12 +1611,11 @@ pending:
|
||||
break;
|
||||
}
|
||||
channel->request_state=SSH_CHANNEL_REQ_STATE_NONE;
|
||||
leave_function();
|
||||
|
||||
return rc;
|
||||
error:
|
||||
buffer_reinit(session->out_buffer);
|
||||
|
||||
leave_function();
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -1695,11 +1652,10 @@ int ssh_channel_request_pty_size(ssh_channel channel, const char *terminal,
|
||||
return rc;
|
||||
}
|
||||
|
||||
enter_function();
|
||||
#ifdef WITH_SSH1
|
||||
if (channel->version==1) {
|
||||
rc = channel_request_pty_size1(channel,terminal, col, row);
|
||||
leave_function();
|
||||
|
||||
return rc;
|
||||
}
|
||||
#endif
|
||||
@@ -1738,7 +1694,6 @@ error:
|
||||
ssh_buffer_free(buffer);
|
||||
ssh_string_free(term);
|
||||
|
||||
leave_function();
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -1778,12 +1733,10 @@ int ssh_channel_change_pty_size(ssh_channel channel, int cols, int rows) {
|
||||
ssh_buffer buffer = NULL;
|
||||
int rc = SSH_ERROR;
|
||||
|
||||
enter_function();
|
||||
|
||||
#ifdef WITH_SSH1
|
||||
if (channel->version == 1) {
|
||||
rc = channel_change_pty_size1(channel,cols,rows);
|
||||
leave_function();
|
||||
|
||||
return rc;
|
||||
}
|
||||
#endif
|
||||
@@ -1806,7 +1759,6 @@ int ssh_channel_change_pty_size(ssh_channel channel, int cols, int rows) {
|
||||
error:
|
||||
ssh_buffer_free(buffer);
|
||||
|
||||
leave_function();
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -2061,7 +2013,6 @@ SSH_PACKET_CALLBACK(ssh_request_success){
|
||||
(void)type;
|
||||
(void)user;
|
||||
(void)packet;
|
||||
enter_function();
|
||||
|
||||
SSH_LOG(SSH_LOG_PACKET,
|
||||
"Received SSH_REQUEST_SUCCESS");
|
||||
@@ -2072,7 +2023,6 @@ SSH_PACKET_CALLBACK(ssh_request_success){
|
||||
session->global_req_state=SSH_CHANNEL_REQ_STATE_ACCEPTED;
|
||||
}
|
||||
|
||||
leave_function();
|
||||
return SSH_PACKET_USED;
|
||||
}
|
||||
|
||||
@@ -2086,7 +2036,6 @@ SSH_PACKET_CALLBACK(ssh_request_denied){
|
||||
(void)type;
|
||||
(void)user;
|
||||
(void)packet;
|
||||
enter_function();
|
||||
|
||||
SSH_LOG(SSH_LOG_PACKET,
|
||||
"Received SSH_REQUEST_FAILURE");
|
||||
@@ -2097,7 +2046,6 @@ SSH_PACKET_CALLBACK(ssh_request_denied){
|
||||
session->global_req_state=SSH_CHANNEL_REQ_STATE_DENIED;
|
||||
}
|
||||
|
||||
leave_function();
|
||||
return SSH_PACKET_USED;
|
||||
|
||||
}
|
||||
@@ -2135,7 +2083,6 @@ static int global_request(ssh_session session, const char *request,
|
||||
ssh_string req = NULL;
|
||||
int rc = SSH_ERROR;
|
||||
|
||||
enter_function();
|
||||
if(session->global_req_state != SSH_CHANNEL_REQ_STATE_NONE)
|
||||
goto pending;
|
||||
req = ssh_string_from_char(request);
|
||||
@@ -2162,7 +2109,6 @@ static int global_request(ssh_session session, const char *request,
|
||||
}
|
||||
session->global_req_state = SSH_CHANNEL_REQ_STATE_PENDING;
|
||||
if (packet_send(session) == SSH_ERROR) {
|
||||
leave_function();
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -2170,7 +2116,7 @@ static int global_request(ssh_session session, const char *request,
|
||||
"Sent a SSH_MSG_GLOBAL_REQUEST %s", request);
|
||||
if (reply == 0) {
|
||||
session->global_req_state=SSH_CHANNEL_REQ_STATE_NONE;
|
||||
leave_function();
|
||||
|
||||
return SSH_OK;
|
||||
}
|
||||
pending:
|
||||
@@ -2200,11 +2146,10 @@ pending:
|
||||
break;
|
||||
}
|
||||
|
||||
leave_function();
|
||||
return rc;
|
||||
error:
|
||||
ssh_string_free(req);
|
||||
leave_function();
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -2595,30 +2540,26 @@ int channel_read_buffer(ssh_channel channel, ssh_buffer buffer, uint32_t count,
|
||||
return SSH_ERROR;
|
||||
}
|
||||
|
||||
enter_function();
|
||||
buffer_reinit(buffer);
|
||||
if(count==0){
|
||||
do {
|
||||
r=ssh_channel_poll(channel, is_stderr);
|
||||
if(r < 0){
|
||||
leave_function();
|
||||
return r;
|
||||
}
|
||||
if(r > 0){
|
||||
r=ssh_channel_read(channel, buffer_tmp, r, is_stderr);
|
||||
if(r < 0){
|
||||
leave_function();
|
||||
return r;
|
||||
}
|
||||
if(buffer_add_data(buffer,buffer_tmp,r) < 0){
|
||||
ssh_set_error_oom(session);
|
||||
r = SSH_ERROR;
|
||||
}
|
||||
leave_function();
|
||||
|
||||
return r;
|
||||
}
|
||||
if(ssh_channel_is_eof(channel)){
|
||||
leave_function();
|
||||
return 0;
|
||||
}
|
||||
ssh_handle_packets(channel->session, SSH_TIMEOUT_INFINITE);
|
||||
@@ -2627,21 +2568,19 @@ int channel_read_buffer(ssh_channel channel, ssh_buffer buffer, uint32_t count,
|
||||
while(total < count){
|
||||
r=ssh_channel_read(channel, buffer_tmp, sizeof(buffer_tmp), is_stderr);
|
||||
if(r<0){
|
||||
leave_function();
|
||||
return r;
|
||||
}
|
||||
if(r==0){
|
||||
leave_function();
|
||||
return total;
|
||||
}
|
||||
if(buffer_add_data(buffer,buffer_tmp,r) < 0){
|
||||
ssh_set_error_oom(session);
|
||||
leave_function();
|
||||
|
||||
return SSH_ERROR;
|
||||
}
|
||||
total += r;
|
||||
}
|
||||
leave_function();
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
@@ -2701,10 +2640,8 @@ int ssh_channel_read(ssh_channel channel, void *dest, uint32_t count, int is_std
|
||||
|
||||
session = channel->session;
|
||||
stdbuf = channel->stdout_buffer;
|
||||
enter_function();
|
||||
|
||||
if (count == 0) {
|
||||
leave_function();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2724,7 +2661,6 @@ int ssh_channel_read(ssh_channel channel, void *dest, uint32_t count, int is_std
|
||||
|
||||
if (count > buffer_get_rest_len(stdbuf) + channel->local_window) {
|
||||
if (grow_window(session, channel, count - buffer_get_rest_len(stdbuf)) < 0) {
|
||||
leave_function();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -2738,15 +2674,12 @@ int ssh_channel_read(ssh_channel channel, void *dest, uint32_t count, int is_std
|
||||
rc = ssh_handle_packets_termination(session, SSH_TIMEOUT_DEFAULT,
|
||||
ssh_channel_read_termination, &ctx);
|
||||
if (rc == SSH_ERROR){
|
||||
leave_function();
|
||||
return rc;
|
||||
}
|
||||
if (channel->session->session_state == SSH_SESSION_STATE_ERROR){
|
||||
leave_function();
|
||||
return SSH_ERROR;
|
||||
}
|
||||
if (channel->remote_eof && buffer_get_rest_len(stdbuf) == 0) {
|
||||
leave_function();
|
||||
return 0;
|
||||
}
|
||||
len = buffer_get_rest_len(stdbuf);
|
||||
@@ -2757,12 +2690,10 @@ int ssh_channel_read(ssh_channel channel, void *dest, uint32_t count, int is_std
|
||||
/* Authorize some buffering while userapp is busy */
|
||||
if (channel->local_window < WINDOWLIMIT) {
|
||||
if (grow_window(session, channel, 0) < 0) {
|
||||
leave_function();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
leave_function();
|
||||
return len;
|
||||
}
|
||||
|
||||
@@ -2803,16 +2734,14 @@ int ssh_channel_read_nonblocking(ssh_channel channel, void *dest, uint32_t count
|
||||
}
|
||||
|
||||
session = channel->session;
|
||||
enter_function();
|
||||
|
||||
to_read = ssh_channel_poll(channel, is_stderr);
|
||||
|
||||
if (to_read <= 0) {
|
||||
if (channel->session->session_state == SSH_SESSION_STATE_ERROR){
|
||||
leave_function();
|
||||
return SSH_ERROR;
|
||||
}
|
||||
leave_function();
|
||||
|
||||
return to_read; /* may be an error code */
|
||||
}
|
||||
|
||||
@@ -2823,7 +2752,7 @@ int ssh_channel_read_nonblocking(ssh_channel channel, void *dest, uint32_t count
|
||||
ssh_set_blocking(session, 0);
|
||||
rc = ssh_channel_read(channel, dest, to_read, is_stderr);
|
||||
ssh_set_blocking(session,blocking);
|
||||
leave_function();
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -2842,16 +2771,13 @@ int ssh_channel_read_nonblocking(ssh_channel channel, void *dest, uint32_t count
|
||||
* @see channel_is_eof()
|
||||
*/
|
||||
int ssh_channel_poll(ssh_channel channel, int is_stderr){
|
||||
ssh_session session;
|
||||
ssh_buffer stdbuf;
|
||||
|
||||
if(channel == NULL) {
|
||||
return SSH_ERROR;
|
||||
}
|
||||
|
||||
session = channel->session;
|
||||
stdbuf = channel->stdout_buffer;
|
||||
enter_function();
|
||||
|
||||
if (is_stderr) {
|
||||
stdbuf = channel->stderr_buffer;
|
||||
@@ -2859,26 +2785,21 @@ int ssh_channel_poll(ssh_channel channel, int is_stderr){
|
||||
|
||||
if (buffer_get_rest_len(stdbuf) == 0 && channel->remote_eof == 0) {
|
||||
if (channel->session->session_state == SSH_SESSION_STATE_ERROR){
|
||||
leave_function();
|
||||
return SSH_ERROR;
|
||||
}
|
||||
if (ssh_handle_packets(channel->session, SSH_TIMEOUT_NONBLOCKING)==SSH_ERROR) {
|
||||
leave_function();
|
||||
return SSH_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (buffer_get_rest_len(stdbuf) > 0){
|
||||
leave_function();
|
||||
return buffer_get_rest_len(stdbuf);
|
||||
}
|
||||
|
||||
if (channel->remote_eof) {
|
||||
leave_function();
|
||||
return SSH_EOF;
|
||||
}
|
||||
|
||||
leave_function();
|
||||
return buffer_get_rest_len(stdbuf);
|
||||
}
|
||||
|
||||
@@ -2913,7 +2834,6 @@ int ssh_channel_poll_timeout(ssh_channel channel, int timeout, int is_stderr){
|
||||
|
||||
session = channel->session;
|
||||
stdbuf = channel->stdout_buffer;
|
||||
enter_function();
|
||||
|
||||
if (is_stderr) {
|
||||
stdbuf = channel->stderr_buffer;
|
||||
@@ -2933,7 +2853,6 @@ int ssh_channel_poll_timeout(ssh_channel channel, int timeout, int is_stderr){
|
||||
if (channel->remote_eof)
|
||||
rc = SSH_EOF;
|
||||
end:
|
||||
leave_function();
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -3252,7 +3171,6 @@ int ssh_channel_open_reverse_forward(ssh_channel channel, const char *remotehost
|
||||
|
||||
session = channel->session;
|
||||
|
||||
enter_function();
|
||||
if(channel->state != SSH_CHANNEL_STATE_NOT_OPEN)
|
||||
goto pending;
|
||||
payload = ssh_buffer_new();
|
||||
@@ -3295,7 +3213,6 @@ error:
|
||||
ssh_buffer_free(payload);
|
||||
ssh_string_free(str);
|
||||
|
||||
leave_function();
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -3332,8 +3249,6 @@ int ssh_channel_open_x11(ssh_channel channel,
|
||||
}
|
||||
session = channel->session;
|
||||
|
||||
enter_function();
|
||||
|
||||
if(channel->state != SSH_CHANNEL_STATE_NOT_OPEN)
|
||||
goto pending;
|
||||
|
||||
@@ -3365,7 +3280,6 @@ error:
|
||||
ssh_buffer_free(payload);
|
||||
ssh_string_free(str);
|
||||
|
||||
leave_function();
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user