channels: set error for new NULL pointer checks

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit 8a83990c16)
This commit is contained in:
Andreas Schneider
2011-02-18 17:57:16 +01:00
parent 9658eade0b
commit b8767be373

View File

@@ -806,7 +806,18 @@ SSH_PACKET_CALLBACK(channel_rcv_request) {
*/
int channel_default_bufferize(ssh_channel channel, void *data, int len,
int is_stderr) {
ssh_session session = channel->session;
ssh_session session;
if(channel == NULL) {
return -1;
}
session = channel->session;
if(data == NULL) {
ssh_set_error_invalid(session, __FUNCTION__);
return -1;
}
ssh_log(session, SSH_LOG_RARE,
"placing %d bytes into channel buffer (stderr=%d)", len, is_stderr);
@@ -892,13 +903,24 @@ int ssh_channel_open_session(ssh_channel channel) {
*/
int ssh_channel_open_forward(ssh_channel channel, const char *remotehost,
int remoteport, const char *sourcehost, int localport) {
ssh_session session = channel->session;
ssh_session session;
ssh_buffer payload = NULL;
ssh_string str = NULL;
int rc = SSH_ERROR;
enter_function();
if (channel == NULL) {
return rc;
}
session = channel->session;
if(remotehost == NULL || sourcehost == NULL) {
ssh_set_error_invalid(session, __FUNCTION__);
return rc;
}
payload = ssh_buffer_new();
if (payload == NULL) {
ssh_set_error_oom(session);
@@ -1081,15 +1103,28 @@ error:
int channel_write_common(ssh_channel channel, const void *data,
uint32_t len, int is_stderr) {
ssh_session session = channel->session;
ssh_session session;
int origlen = len;
size_t effectivelen;
/* handle the max packet len from remote side, be nice */
/* 10 bytes for the headers */
size_t maxpacketlen = channel->remote_maxpacket - 10;
size_t maxpacketlen;
if(channel == NULL || data == NULL) {
return -1;
}
session = channel->session;
if(data == NULL) {
ssh_set_error_invalid(session, __FUNCTION__);
return -1;
}
enter_function();
/*
* Handle the max packet len from remote side, be nice
* 10 bytes for the headers
*/
maxpacketlen = channel->remote_maxpacket - 10;
if (channel->local_eof) {
ssh_set_error(session, SSH_REQUEST_DENIED,
"Can't write to channel %d:%d after EOF was sent",
@@ -2824,6 +2859,15 @@ int ssh_channel_request_send_exit_signal(ssh_channel channel, const char *sig, i
ssh_string tmp = NULL;
int rc = SSH_ERROR;
if(channel == NULL) {
return rc;
}
if(sig == NULL || errmsg == NULL || lang == NULL) {
ssh_set_error_invalid(channel->session, __FUNCTION__);
return rc;
}
#ifdef WITH_SSH1
if (channel->version == 1) {
return SSH_ERROR; // TODO: Add support for SSH-v1 if possible.