[Spice-devel] [PATCH spice-server v2 2/2] reds: Fix leaks if reds_init_client_ssl_connection fails

Christophe Fergeau cfergeau at redhat.com
Tue Sep 12 10:52:51 UTC 2017


Acked-by: Christophe Fergeau <cfergeau at redhat.com>

On Tue, Sep 12, 2017 at 09:03:16AM +0100, Frediano Ziglio wrote:
> If a client is unable to complete the TLS handshake phase
> reds_init_client_ssl_connection leaked some memory as the stream is not
> correctly freed.
> This also causes the stream to send the SPICE_CHANNEL_EVENT_DISCONNECTED
> event. Otherwise only SPICE_CHANNEL_EVENT_CONNECTED was sent.
> 
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
>  server/reds.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> Changes since v1:
> - reuse reds_link_free.
> 
> diff --git a/server/reds.c b/server/reds.c
> index 24ec2bdde..a73d00f75 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -2503,9 +2503,10 @@ static RedLinkInfo *reds_init_client_ssl_connection(RedsState *reds, int socket)
>      return link;
>  
>  error:
> -    free(link->stream);
> -    BN_free(link->tiTicketing.bn);
> -    free(link);
> +    /* close the stream but do not close the socket, this API is
> +     * supposed to not close it if it fails */
> +    link->stream->socket = -1;
> +    reds_link_free(link);
>      return NULL;
>  }
>  
> -- 
> 2.13.5
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel


More information about the Spice-devel mailing list