mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-09 18:04:25 +09:00
Add error checking to ssh message type functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@452 7dcaeef0-15fb-0310-b436-a5af3365683c
This commit is contained in:
@@ -710,40 +710,51 @@ error:
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ssh_message_type(SSH_MESSAGE *msg){
|
int ssh_message_type(SSH_MESSAGE *msg) {
|
||||||
return msg->type;
|
if (msg == NULL) {
|
||||||
}
|
|
||||||
|
|
||||||
int ssh_message_subtype(SSH_MESSAGE *msg){
|
|
||||||
switch(msg->type){
|
|
||||||
case SSH_AUTH_REQUEST:
|
|
||||||
return msg->auth_request.method;
|
|
||||||
case SSH_CHANNEL_REQUEST_OPEN:
|
|
||||||
return msg->channel_request_open.type;
|
|
||||||
case SSH_CHANNEL_REQUEST:
|
|
||||||
return msg->channel_request.type;
|
|
||||||
}
|
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return msg->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ssh_message_reply_default(SSH_MESSAGE *msg){
|
int ssh_message_subtype(SSH_MESSAGE *msg) {
|
||||||
switch(msg->type){
|
if (msg == NULL) {
|
||||||
case SSH_AUTH_REQUEST:
|
return -1;
|
||||||
return ssh_message_auth_reply_default(msg,0);
|
}
|
||||||
break;
|
|
||||||
case SSH_CHANNEL_REQUEST_OPEN:
|
switch(msg->type) {
|
||||||
return ssh_message_channel_request_open_reply_default(msg);
|
case SSH_AUTH_REQUEST:
|
||||||
break;
|
return msg->auth_request.method;
|
||||||
case SSH_CHANNEL_REQUEST:
|
case SSH_CHANNEL_REQUEST_OPEN:
|
||||||
return ssh_message_channel_request_reply_default(msg);
|
return msg->channel_request_open.type;
|
||||||
break;
|
case SSH_CHANNEL_REQUEST:
|
||||||
default:
|
return msg->channel_request.type;
|
||||||
ssh_log(msg->session, SSH_LOG_PACKET,
|
}
|
||||||
"Don't know what to default reply to %d type",
|
|
||||||
msg->type);
|
return -1;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
return 0;
|
int ssh_message_reply_default(SSH_MESSAGE *msg) {
|
||||||
|
if (msg == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(msg->type) {
|
||||||
|
case SSH_AUTH_REQUEST:
|
||||||
|
return ssh_message_auth_reply_default(msg, 0);
|
||||||
|
case SSH_CHANNEL_REQUEST_OPEN:
|
||||||
|
return ssh_message_channel_request_open_reply_default(msg);
|
||||||
|
case SSH_CHANNEL_REQUEST:
|
||||||
|
return ssh_message_channel_request_reply_default(msg);
|
||||||
|
default:
|
||||||
|
ssh_log(msg->session, SSH_LOG_PACKET,
|
||||||
|
"Don't know what to default reply to %d type",
|
||||||
|
msg->type);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ssh_message_free(SSH_MESSAGE *msg){
|
void ssh_message_free(SSH_MESSAGE *msg){
|
||||||
|
|||||||
Reference in New Issue
Block a user