[gtk-vnc] src: fix mem leaks in SASL, rich cursor and xcursor code
- From: Daniel P. Berrange <dberrange src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk-vnc] src: fix mem leaks in SASL, rich cursor and xcursor code
- Date: Tue, 30 Mar 2021 13:52:27 +0000 (UTC)
commit 603b5cf4dbe13947df44b2c65ade8130e85edf94
Author: Daniel P. Berrangé <dan berrange com>
Date: Tue Mar 23 10:54:26 2021 +0000
src: fix mem leaks in SASL, rich cursor and xcursor code
Signed-off-by: Daniel P. Berrangé <berrange redhat com>
src/vncconnection.c | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
---
diff --git a/src/vncconnection.c b/src/vncconnection.c
index 2426afd..2d79a92 100644
--- a/src/vncconnection.c
+++ b/src/vncconnection.c
@@ -3060,8 +3060,12 @@ static void vnc_connection_rich_cursor(VncConnection *conn, guint16 x, guint16 y
vnc_connection_read(conn, image, imagelen);
vnc_connection_read(conn, mask, masklen);
- if (vnc_connection_has_error(conn))
+ if (vnc_connection_has_error(conn)) {
+ g_free(image);
+ g_free(mask);
+ g_free(pixbuf);
return;
+ }
vnc_connection_rich_cursor_blt(conn, pixbuf, image, mask,
width * (priv->fmt.bits_per_pixel/8),
@@ -3120,8 +3124,13 @@ static void vnc_connection_xcursor(VncConnection *conn, guint16 x, guint16 y, gu
vnc_connection_read(conn, data, rowlen*height);
vnc_connection_read(conn, mask, rowlen*height);
- if (vnc_connection_has_error(conn))
+ if (vnc_connection_has_error(conn)) {
+ g_free(data);
+ g_free(mask);
+ g_free(pixbuf);
return;
+ }
+
datap = data;
maskp = mask;
pixp = (guint32*)pixbuf;
@@ -4377,7 +4386,7 @@ static gboolean vnc_connection_perform_auth_sasl(VncConnection *conn)
};
sasl_interact_t *interact = NULL;
guint32 mechlistlen;
- char *mechlist;
+ char *mechlist = NULL;
const char *mechname;
gboolean ret;
GSocketAddress *addr;
@@ -4491,11 +4500,8 @@ static gboolean vnc_connection_perform_auth_sasl(VncConnection *conn)
mechlist = g_malloc(mechlistlen+1);
vnc_connection_read(conn, mechlist, mechlistlen);
mechlist[mechlistlen] = '\0';
- if (vnc_connection_has_error(conn)) {
- g_free(mechlist);
- mechlist = NULL;
+ if (vnc_connection_has_error(conn))
goto error;
- }
restart:
/* Start the auth negotiation on the client end first */
@@ -4510,8 +4516,6 @@ static gboolean vnc_connection_perform_auth_sasl(VncConnection *conn)
vnc_connection_set_error(conn,
"Failed to start SASL negotiation: %d (%s)",
err, sasl_errdetail(saslconn));
- g_free(mechlist);
- mechlist = NULL;
goto error;
}
@@ -4701,12 +4705,14 @@ static gboolean vnc_connection_perform_auth_sasl(VncConnection *conn)
* is defined to be sent unencrypted, and setting saslconn turns
* on the SSF layer encryption processing */
priv->saslconn = saslconn;
+ g_free(mechlist);
return ret;
error:
if (saslconn)
sasl_dispose(&saslconn);
vnc_connection_auth_failure(conn, "Unknown authentication failure");
+ g_free(mechlist);
return FALSE;
}
#endif /* HAVE_SASL */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]