mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-09 09:54:25 +09:00
Add more error checks to ssh_message_get().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@451 7dcaeef0-15fb-0310-b436-a5af3365683c
This commit is contained in:
@@ -658,47 +658,56 @@ static int ssh_message_channel_request_reply_default(SSH_MESSAGE *msg) {
|
|||||||
return SSH_OK;
|
return SSH_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSH_MESSAGE *ssh_message_get(SSH_SESSION *session){
|
SSH_MESSAGE *ssh_message_get(SSH_SESSION *session) {
|
||||||
SSH_MESSAGE *ret;
|
SSH_MESSAGE *msg = NULL;
|
||||||
enter_function();
|
|
||||||
while(1){
|
enter_function();
|
||||||
if(packet_read(session) || packet_translate(session)){
|
|
||||||
leave_function();
|
if (msg == NULL) {
|
||||||
return NULL;
|
goto error;
|
||||||
}
|
}
|
||||||
switch(session->in_packet.type){
|
|
||||||
case SSH2_MSG_SERVICE_REQUEST:
|
do {
|
||||||
if(handle_service_request(session)){
|
if ((packet_read(session) != SSH_OK) ||
|
||||||
leave_function();
|
(packet_translate(session) != SSH_OK)) {
|
||||||
return NULL;
|
goto error;
|
||||||
}
|
|
||||||
break;
|
|
||||||
case SSH2_MSG_IGNORE:
|
|
||||||
case SSH2_MSG_DEBUG:
|
|
||||||
break;
|
|
||||||
case SSH2_MSG_USERAUTH_REQUEST:
|
|
||||||
ret = handle_userauth_request(session);
|
|
||||||
leave_function();
|
|
||||||
return ret;
|
|
||||||
case SSH2_MSG_CHANNEL_OPEN:
|
|
||||||
ret = handle_channel_request_open(session);
|
|
||||||
leave_function();
|
|
||||||
return ret;
|
|
||||||
case SSH2_MSG_CHANNEL_REQUEST:
|
|
||||||
ret = handle_channel_request(session);
|
|
||||||
leave_function();
|
|
||||||
return ret;
|
|
||||||
default:
|
|
||||||
if (handle_unimplemented(session) == 0) {
|
|
||||||
ssh_set_error(session, SSH_FATAL,
|
|
||||||
"Unhandled message %d\n", session->in_packet.type);
|
|
||||||
}
|
|
||||||
leave_function();
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
leave_function();
|
switch(session->in_packet.type) {
|
||||||
return NULL;
|
case SSH2_MSG_SERVICE_REQUEST:
|
||||||
|
if (handle_service_request(session) < 0) {
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SSH2_MSG_IGNORE:
|
||||||
|
case SSH2_MSG_DEBUG:
|
||||||
|
break;
|
||||||
|
case SSH2_MSG_USERAUTH_REQUEST:
|
||||||
|
msg = handle_userauth_request(session);
|
||||||
|
|
||||||
|
leave_function();
|
||||||
|
return msg;
|
||||||
|
case SSH2_MSG_CHANNEL_OPEN:
|
||||||
|
msg = handle_channel_request_open(session);
|
||||||
|
|
||||||
|
leave_function();
|
||||||
|
return msg;
|
||||||
|
case SSH2_MSG_CHANNEL_REQUEST:
|
||||||
|
msg = handle_channel_request(session);
|
||||||
|
leave_function();
|
||||||
|
|
||||||
|
return msg;
|
||||||
|
default:
|
||||||
|
if (handle_unimplemented(session) == 0) {
|
||||||
|
ssh_set_error(session, SSH_FATAL,
|
||||||
|
"Unhandled message %d\n", session->in_packet.type);
|
||||||
|
}
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
} while(1);
|
||||||
|
|
||||||
|
error:
|
||||||
|
leave_function();
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ssh_message_type(SSH_MESSAGE *msg){
|
int ssh_message_type(SSH_MESSAGE *msg){
|
||||||
|
|||||||
Reference in New Issue
Block a user