summaryrefslogtreecommitdiffstats
path: root/libssh/messages.c
diff options
context:
space:
mode:
authorAndreas Schneider <mail@cynapses.org>2009-04-09 15:29:13 +0000
committerAndreas Schneider <mail@cynapses.org>2009-04-09 15:29:13 +0000
commit3ad76af46922dac385f8ea8fb464e56c49a73a6b (patch)
tree36798640796d347c75e0c170659e02219ddc8801 /libssh/messages.c
parent926375e8aa87902459a342c9fefcc81595f360cf (diff)
downloadlibssh-3ad76af46922dac385f8ea8fb464e56c49a73a6b.tar.gz
libssh-3ad76af46922dac385f8ea8fb464e56c49a73a6b.tar.xz
libssh-3ad76af46922dac385f8ea8fb464e56c49a73a6b.zip
Add error checking to ssh_message_channel_request_open_reply_default().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@447 7dcaeef0-15fb-0310-b436-a5af3365683c
Diffstat (limited to 'libssh/messages.c')
-rw-r--r--libssh/messages.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/libssh/messages.c b/libssh/messages.c
index 0af88cc..5fb2314 100644
--- a/libssh/messages.c
+++ b/libssh/messages.c
@@ -429,14 +429,33 @@ error:
return NULL;
}
-static int ssh_message_channel_request_open_reply_default(SSH_MESSAGE *msg){
- ssh_log(msg->session, SSH_LOG_FUNCTIONS, "Refusing a channel");
- buffer_add_u8(msg->session->out_buffer,SSH2_MSG_CHANNEL_OPEN_FAILURE);
- buffer_add_u32(msg->session->out_buffer,htonl(msg->channel_request_open.sender));
- buffer_add_u32(msg->session->out_buffer,htonl(SSH2_OPEN_ADMINISTRATIVELY_PROHIBITED));
- buffer_add_u32(msg->session->out_buffer,0); // reason is an empty string
- buffer_add_u32(msg->session->out_buffer,0); // language too
- return packet_send(msg->session);
+static int ssh_message_channel_request_open_reply_default(SSH_MESSAGE *msg) {
+ ssh_log(msg->session, SSH_LOG_FUNCTIONS, "Refusing a channel");
+
+ if (buffer_add_u8(msg->session->out_buffer
+ , SSH2_MSG_CHANNEL_OPEN_FAILURE) < 0) {
+ goto error;
+ }
+ if (buffer_add_u32(msg->session->out_buffer,
+ htonl(msg->channel_request_open.sender)) < 0) {
+ goto error;
+ }
+ if (buffer_add_u32(msg->session->out_buffer,
+ htonl(SSH2_OPEN_ADMINISTRATIVELY_PROHIBITED)) < 0) {
+ goto error;
+ }
+ /* reason is an empty string */
+ if (buffer_add_u32(msg->session->out_buffer, 0) < 0) {
+ goto error;
+ }
+ /* language too */
+ if (buffer_add_u32(msg->session->out_buffer, 0) < 0) {
+ goto error;
+ }
+
+ return packet_send(msg->session);
+error:
+ return SSH_ERROR;
}
static SSH_MESSAGE *handle_channel_request(SSH_SESSION *session){