1
1

Add error checking to handle_channel_request_open().

git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@445 7dcaeef0-15fb-0310-b436-a5af3365683c
Этот коммит содержится в:
Andreas Schneider 2009-04-09 14:28:23 +00:00
родитель 38d8875021
Коммит a8bb3024e8

Просмотреть файл

@ -314,39 +314,61 @@ int ssh_message_auth_reply_success(SSH_MESSAGE *msg, int partial) {
return packet_send(msg->session); return packet_send(msg->session);
} }
static SSH_MESSAGE *handle_channel_request_open(SSH_SESSION *session){ static SSH_MESSAGE *handle_channel_request_open(SSH_SESSION *session) {
SSH_MESSAGE *msg; SSH_MESSAGE *msg = NULL;
STRING *type; STRING *type = NULL;
char *type_c; char *type_c = NULL;
u32 sender, window, packet; u32 sender, window, packet;
enter_function(); enter_function();
msg = message_new(session);
if (msg == NULL) { msg = message_new(session);
return NULL; if (msg == NULL) {
} return NULL;
msg->type=SSH_CHANNEL_REQUEST_OPEN; }
type=buffer_get_ssh_string(session->in_buffer);
type_c=string_to_char(type); msg->type = SSH_CHANNEL_REQUEST_OPEN;
ssh_log(session, SSH_LOG_PACKET,
"Clients wants to open a %s channel", type_c); type = buffer_get_ssh_string(session->in_buffer);
free(type); if (type == NULL) {
buffer_get_u32(session->in_buffer,&sender); goto error;
buffer_get_u32(session->in_buffer,&window); }
buffer_get_u32(session->in_buffer,&packet); type_c = string_to_char(type);
msg->channel_request_open.sender=ntohl(sender); if (type_c == NULL) {
msg->channel_request_open.window=ntohl(window); goto error;
msg->channel_request_open.packet_size=ntohl(packet); }
if(!strcmp(type_c,"session")){
msg->channel_request_open.type=SSH_CHANNEL_SESSION; ssh_log(session, SSH_LOG_PACKET,
free(type_c); "Clients wants to open a %s channel", type_c);
leave_function(); string_free(type);
return msg;
} buffer_get_u32(session->in_buffer, &sender);
msg->channel_request_open.type=SSH_CHANNEL_UNKNOWN; buffer_get_u32(session->in_buffer, &window);
free(type_c); buffer_get_u32(session->in_buffer, &packet);
msg->channel_request_open.sender = ntohl(sender);
msg->channel_request_open.window = ntohl(window);
msg->channel_request_open.packet_size = ntohl(packet);
if (strcmp(type_c,"session") == 0) {
msg->channel_request_open.type = SSH_CHANNEL_SESSION;
SAFE_FREE(type_c);
leave_function(); leave_function();
return msg; return msg;
}
msg->channel_request_open.type = SSH_CHANNEL_UNKNOWN;
SAFE_FREE(type_c);
leave_function();
return msg;
error:
string_free(type);
SAFE_FREE(type_c);
ssh_message_free(msg);
leave_function();
return NULL;
} }
CHANNEL *ssh_message_channel_request_open_reply_accept(SSH_MESSAGE *msg){ CHANNEL *ssh_message_channel_request_open_reply_accept(SSH_MESSAGE *msg){