Subject: Re: libssh2 master 4cf935a inputchecks: make lots of API functions check for NULL pointers

Re: libssh2 master 4cf935a inputchecks: make lots of API functions check for NULL pointers

From: Alexander Lamaison <swish_at_lammy.co.uk>
Date: Fri, 11 Jun 2010 12:16:10 +0100

On 11 June 2010 12:08, <libssh2_at_git.stuge.se> wrote:
> commit 4cf935abab997ca7882fe832324ba4e724c5af61
> Author: Daniel Stenberg <daniel_at_haxx.se>
> Commit: Daniel Stenberg <daniel_at_haxx.se>
>
>    inputchecks: make lots of API functions check for NULL pointers
>
>    If an application accidentally provides a NULL handle pointer to
>    the channel or sftp public functions, they now return an error
>    instead of segfaulting.
>
> diff --git a/src/channel.c b/src/channel.c
> index 61a2353..966e63d 100644
> --- a/src/channel.c
> +++ b/src/channel.c
> @@ -329,6 +329,10 @@ libssh2_channel_open_ex(LIBSSH2_SESSION *session, const char *type,
>                         const char *msg, unsigned int msg_len)
>  {
>     LIBSSH2_CHANNEL *ptr;
> +
> +    if(!session)
> +        return NULL;
> +

<snip>

These should all call _libssh2_error before returning NULL or and error code.

Alex
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2010-06-11