summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2011-02-18 17:57:16 +0100
committerAndreas Schneider <asn@cryptomilk.org>2011-02-18 18:01:45 +0100
commitb8767be373242917dcb78654fdd2e97acf1dbee1 (patch)
tree0bf5a607243e83158f8333e765a4d0e930e56e03 /src
parent9658eade0baf6d65c1761fd8bfde0ad8d53ed43e (diff)
downloadlibssh-b8767be373242917dcb78654fdd2e97acf1dbee1.tar.gz
libssh-b8767be373242917dcb78654fdd2e97acf1dbee1.tar.xz
libssh-b8767be373242917dcb78654fdd2e97acf1dbee1.zip
channels: set error for new NULL pointer checks
Signed-off-by: Andreas Schneider <asn@cryptomilk.org> (cherry picked from commit 8a83990c1603a051e74d5aa7a60445a7ef5021e4)
Diffstat (limited to 'src')
-rw-r--r--src/channels.c56
1 files changed, 50 insertions, 6 deletions
diff --git a/src/channels.c b/src/channels.c
index e5dbec5b..34ce069c 100644
--- a/src/channels.c
+++ b/src/channels.c
@@ -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.