1
1

Added more error messages and checking to handle_channel_request.

Этот коммит содержится в:
Andreas Schneider 2009-11-18 14:56:12 +01:00
родитель d60b1ec1a2
Коммит 11cc5f5815

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

@ -299,6 +299,7 @@ static ssh_message handle_channel_request_open(ssh_session session) {
msg = message_new(session); msg = message_new(session);
if (msg == NULL) { if (msg == NULL) {
ssh_set_error_oom(session);
leave_function(); leave_function();
return NULL; return NULL;
} }
@ -307,10 +308,12 @@ static ssh_message handle_channel_request_open(ssh_session session) {
type = buffer_get_ssh_string(session->in_buffer); type = buffer_get_ssh_string(session->in_buffer);
if (type == NULL) { if (type == NULL) {
ssh_set_error_oom(session);
goto error; goto error;
} }
type_c = string_to_char(type); type_c = string_to_char(type);
if (type_c == NULL) { if (type_c == NULL) {
ssh_set_error_oom(session);
goto error; goto error;
} }
@ -336,10 +339,12 @@ static ssh_message handle_channel_request_open(ssh_session session) {
if (strcmp(type_c,"direct-tcpip") == 0) { if (strcmp(type_c,"direct-tcpip") == 0) {
destination = buffer_get_ssh_string(session->in_buffer); destination = buffer_get_ssh_string(session->in_buffer);
if (destination == NULL) { if (destination == NULL) {
ssh_set_error_oom(session);
goto error; goto error;
} }
msg->channel_request_open.destination = string_to_char(type); msg->channel_request_open.destination = string_to_char(type);
if (msg->channel_request_open.destination == NULL) { if (msg->channel_request_open.destination == NULL) {
ssh_set_error_oom(session);
string_free(destination); string_free(destination);
goto error; goto error;
} }
@ -350,10 +355,12 @@ static ssh_message handle_channel_request_open(ssh_session session) {
originator = buffer_get_ssh_string(session->in_buffer); originator = buffer_get_ssh_string(session->in_buffer);
if (originator == NULL) { if (originator == NULL) {
ssh_set_error_oom(session);
goto error; goto error;
} }
msg->channel_request_open.originator = string_to_char(type); msg->channel_request_open.originator = string_to_char(type);
if (msg->channel_request_open.originator == NULL) { if (msg->channel_request_open.originator == NULL) {
ssh_set_error_oom(session);
string_free(originator); string_free(originator);
goto error; goto error;
} }
@ -371,10 +378,12 @@ static ssh_message handle_channel_request_open(ssh_session session) {
if (strcmp(type_c,"forwarded-tcpip") == 0) { if (strcmp(type_c,"forwarded-tcpip") == 0) {
destination = buffer_get_ssh_string(session->in_buffer); destination = buffer_get_ssh_string(session->in_buffer);
if (destination == NULL) { if (destination == NULL) {
ssh_set_error_oom(session);
goto error; goto error;
} }
msg->channel_request_open.destination = string_to_char(type); msg->channel_request_open.destination = string_to_char(type);
if (msg->channel_request_open.destination == NULL) { if (msg->channel_request_open.destination == NULL) {
ssh_set_error_oom(session);
string_free(destination); string_free(destination);
goto error; goto error;
} }
@ -385,10 +394,12 @@ static ssh_message handle_channel_request_open(ssh_session session) {
originator = buffer_get_ssh_string(session->in_buffer); originator = buffer_get_ssh_string(session->in_buffer);
if (originator == NULL) { if (originator == NULL) {
ssh_set_error_oom(session);
goto error; goto error;
} }
msg->channel_request_open.originator = string_to_char(type); msg->channel_request_open.originator = string_to_char(type);
if (msg->channel_request_open.originator == NULL) { if (msg->channel_request_open.originator == NULL) {
ssh_set_error_oom(session);
string_free(originator); string_free(originator);
goto error; goto error;
} }
@ -406,10 +417,12 @@ static ssh_message handle_channel_request_open(ssh_session session) {
if (strcmp(type_c,"x11") == 0) { if (strcmp(type_c,"x11") == 0) {
originator = buffer_get_ssh_string(session->in_buffer); originator = buffer_get_ssh_string(session->in_buffer);
if (originator == NULL) { if (originator == NULL) {
ssh_set_error_oom(session);
goto error; goto error;
} }
msg->channel_request_open.originator = string_to_char(type); msg->channel_request_open.originator = string_to_char(type);
if (msg->channel_request_open.originator == NULL) { if (msg->channel_request_open.originator == NULL) {
ssh_set_error_oom(session);
string_free(originator); string_free(originator);
goto error; goto error;
} }
@ -506,6 +519,7 @@ static ssh_message handle_channel_request(ssh_session session) {
msg = message_new(session); msg = message_new(session);
if (msg == NULL) { if (msg == NULL) {
ssh_set_error_oom(session);
return NULL; return NULL;
} }
@ -514,10 +528,12 @@ static ssh_message handle_channel_request(ssh_session session) {
type = buffer_get_ssh_string(session->in_buffer); type = buffer_get_ssh_string(session->in_buffer);
if (type == NULL) { if (type == NULL) {
ssh_set_error_oom(session);
goto error; goto error;
} }
type_c = string_to_char(type); type_c = string_to_char(type);
if (type_c == NULL) { if (type_c == NULL) {
ssh_set_error_oom(session);
goto error; goto error;
} }
string_free(type); string_free(type);
@ -530,6 +546,11 @@ static ssh_message handle_channel_request(ssh_session session) {
msg->type = SSH_REQUEST_CHANNEL; msg->type = SSH_REQUEST_CHANNEL;
msg->channel_request.channel = ssh_channel_from_local(session, channel); msg->channel_request.channel = ssh_channel_from_local(session, channel);
if (msg->channel_request.channel == NULL) {
ssh_set_error(session, SSH_FATAL, "There are no channels with the id %u.",
channels);
goto error;
}
msg->channel_request.want_reply = want_reply; msg->channel_request.want_reply = want_reply;
if (strcmp(type_c, "pty-req") == 0) { if (strcmp(type_c, "pty-req") == 0) {
@ -539,10 +560,12 @@ static ssh_message handle_channel_request(ssh_session session) {
term = buffer_get_ssh_string(session->in_buffer); term = buffer_get_ssh_string(session->in_buffer);
if (term == NULL) { if (term == NULL) {
ssh_set_error_oom(session);
goto error; goto error;
} }
term_c = string_to_char(term); term_c = string_to_char(term);
if (term_c == NULL) { if (term_c == NULL) {
ssh_set_error_oom(session);
string_free(term); string_free(term);
goto error; goto error;
} }
@ -597,10 +620,12 @@ static ssh_message handle_channel_request(ssh_session session) {
subsys = buffer_get_ssh_string(session->in_buffer); subsys = buffer_get_ssh_string(session->in_buffer);
if (subsys == NULL) { if (subsys == NULL) {
ssh_set_error_oom(session);
goto error; goto error;
} }
subsys_c = string_to_char(subsys); subsys_c = string_to_char(subsys);
if (subsys_c == NULL) { if (subsys_c == NULL) {
ssh_set_error_oom(session);
string_free(subsys); string_free(subsys);
goto error; goto error;
} }
@ -628,6 +653,7 @@ static ssh_message handle_channel_request(ssh_session session) {
cmd = buffer_get_ssh_string(session->in_buffer); cmd = buffer_get_ssh_string(session->in_buffer);
if (cmd == NULL) { if (cmd == NULL) {
ssh_set_error_oom(session);
goto error; goto error;
} }
@ -651,10 +677,12 @@ static ssh_message handle_channel_request(ssh_session session) {
name = buffer_get_ssh_string(session->in_buffer); name = buffer_get_ssh_string(session->in_buffer);
if (name == NULL) { if (name == NULL) {
ssh_set_error_oom(session);
goto error; goto error;
} }
value = buffer_get_ssh_string(session->in_buffer); value = buffer_get_ssh_string(session->in_buffer);
if (value == NULL) { if (value == NULL) {
ssh_set_error_oom(session);
string_free(name); string_free(name);
goto error; goto error;
} }