[Spice-commits] 2 commits - gtk/Makefile.am gtk/bio-gio.c gtk/channel-base.c gtk/channel-cursor.c gtk/channel-display-mjpeg.c gtk/channel-inputs.c gtk/channel-main.c gtk/channel-playback.c gtk/channel-port.c gtk/channel-record.c gtk/decode-glz.c gtk/decode-jpeg.c gtk/decode-zlib.c gtk/gio-coroutine.c gtk/glib-compat.c gtk/spice-channel.c gtk/spice-client.c gtk/spice-gtk-session.c gtk/spice-pulse.c gtk/spice-session.c gtk/spice-uri.c gtk/spice-widget-cairo.c gtk/spice-widget-x11.c gtk/spice-widget.c gtk/vmcstream.c gtk/vncdisplaykeymap.c

Christophe Fergau teuf at kemper.freedesktop.org
Thu Mar 13 09:19:41 PDT 2014


 gtk/Makefile.am             |    9 ++++++---
 gtk/bio-gio.c               |    1 +
 gtk/channel-base.c          |    2 ++
 gtk/channel-cursor.c        |    2 ++
 gtk/channel-display-mjpeg.c |    2 ++
 gtk/channel-inputs.c        |    2 ++
 gtk/channel-main.c          |    2 ++
 gtk/channel-playback.c      |    2 ++
 gtk/channel-port.c          |    2 ++
 gtk/channel-record.c        |    2 ++
 gtk/decode-glz.c            |    2 ++
 gtk/decode-jpeg.c           |    2 ++
 gtk/decode-zlib.c           |    2 ++
 gtk/gio-coroutine.c         |    1 +
 gtk/glib-compat.c           |    1 +
 gtk/spice-channel.c         |   23 +++++++++++++----------
 gtk/spice-client.c          |    2 ++
 gtk/spice-gtk-session.c     |    1 +
 gtk/spice-pulse.c           |    2 ++
 gtk/spice-session.c         |    2 ++
 gtk/spice-uri.c             |    1 +
 gtk/spice-widget-cairo.c    |    6 ++----
 gtk/spice-widget-x11.c      |    6 ++----
 gtk/spice-widget.c          |    6 ++----
 gtk/vmcstream.c             |    2 ++
 gtk/vncdisplaykeymap.c      |    1 +
 26 files changed, 61 insertions(+), 25 deletions(-)

New commits:
commit 76724d7cb6089b0b91b1cb19ca06f4f6ac145db7
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Fri Oct 11 19:56:25 2013 +0200

    sasl: Rework memory handling in spice_channel_perform_auth_sasl()
    
    While looking at the SASL code, I noticed some memory leaks in error paths.
    This commit adds a cleanup: block to free some of the memory dynamically
    allocated in that function, and remove the corresponding g_free() from
    the regular code flow. This should ensure that both the regular path
    and the error paths free the same memory.
    
    This fixes at least this 'mechlist' leak which I got during regular SASL
    PLAIN authentication:
    ==3452== 6 bytes in 1 blocks are definitely lost in loss record 140 of 11,706
    ==3452==    at 0x4A0645D: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.s
    ==3452==    by 0x35BAC4EE6E: g_malloc (gmem.c:104)
    ==3452==    by 0x5BF7CAA: spice_channel_perform_auth_sasl (spice-channel.c:1440)
    ==3452==    by 0x5BF9033: spice_channel_recv_link_msg (spice-channel.c:1727)
    ==3452==    by 0x5BFAECD: spice_channel_coroutine (spice-channel.c:2348)
    ==3452==    by 0x5C35D6D: coroutine_trampoline (coroutine_ucontext.c:63)
    ==3452==    by 0x5C35A1B: continuation_trampoline (continuation.c:51)
    ==3452==    by 0x31342479BF: ??? (in /usr/lib64/libc-2.18.so)
    ==3452==    by 0x75F2940591224CFF: ???
    ==3452==    by 0xE756E5F: ???
    ==3452==    by 0xE7589BF: ???
    ==3452==    by 0xFFEFFF78F: ???
    ==3452==    by 0x5BFCD92: g_io_wait_helper (gio-coroutine.c:43)
    =

diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index ace8b94..83c7006 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -1348,7 +1348,7 @@ static gboolean spice_channel_perform_auth_sasl(SpiceChannel *channel)
     };
     sasl_interact_t *interact = NULL;
     guint32 len;
-    char *mechlist;
+    char *mechlist = NULL;
     const char *mechname;
     gboolean ret = FALSE;
     GSocketAddress *addr = NULL;
@@ -1403,8 +1403,6 @@ static gboolean spice_channel_perform_auth_sasl(SpiceChannel *channel)
                           saslcb,
                           SASL_SUCCESS_DATA,
                           &saslconn);
-    g_free(localAddr);
-    g_free(remoteAddr);
 
     if (err != SASL_OK) {
         g_critical("Failed to create SASL client context: %d (%s)",
@@ -1453,8 +1451,6 @@ static gboolean spice_channel_perform_auth_sasl(SpiceChannel *channel)
     spice_channel_read(channel, mechlist, len);
     mechlist[len] = '\0';
     if (c->has_error) {
-        g_free(mechlist);
-        mechlist = NULL;
         goto error;
     }
 
@@ -1470,8 +1466,6 @@ restart:
     if (err != SASL_OK && err != SASL_CONTINUE && err != SASL_INTERACT) {
         g_critical("Failed to start SASL negotiation: %d (%s)",
                    err, sasl_errdetail(saslconn));
-        g_free(mechlist);
-        mechlist = NULL;
         goto error;
     }
 
@@ -1657,15 +1651,22 @@ complete:
      * is defined to be sent unencrypted, and setting saslconn turns
      * on the SSF layer encryption processing */
     c->sasl_conn = saslconn;
-    return ret;
+    goto cleanup;
 
 error:
-    g_clear_object(&addr);
     if (saslconn)
         sasl_dispose(&saslconn);
     emit_main_context(channel, SPICE_CHANNEL_EVENT, SPICE_CHANNEL_ERROR_AUTH);
     c->has_error = TRUE; /* force disconnect */
-    return FALSE;
+    ret = FALSE;
+
+cleanup:
+    g_free(localAddr);
+    g_free(remoteAddr);
+    g_free(mechlist);
+    g_free(serverin);
+    g_clear_object(&addr);
+    return ret;
 }
 #endif /* HAVE_SASL */
 
commit b7c9343ba20abd93429a37b475920cde97bf01e8
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Thu Feb 27 12:33:28 2014 +0100

    Make sure config.h is included first in all .c files
    
    This is recommended by autoconf documentation
    http://nondot.org/sabre/Mirrored/autoconf-2.12/autoconf_3.html#SEC15
    and some #defines in config.h can change what happens in system headers,
    so config.h has to be included first.
    
    The only file which does not get this treatment is
    gtk/spice-client-gtk-module.c as this breaks the build on gtk+2:
    
    CC       SpiceClientGtk_la-spice-client-gtk-module.lo
    In file included from /usr/include/python2.7/pyconfig.h:6:0,
                     from /usr/include/python2.7/Python.h:8,
                     from /usr/include/pygtk-2.0/pygobject.h:5,
                     from spice-client-gtk-module.c:20:
    /usr/include/python2.7/pyconfig-64.h:1182:0: error: "_POSIX_C_SOURCE" redefined [-Werror]
     #define _POSIX_C_SOURCE 200112L
     ^
    In file included from /usr/include/limits.h:25:0,
                     from /usr/lib/gcc/x86_64-redhat-linux/4.8.2/include/limits.h:168,
                     from /usr/lib/gcc/x86_64-redhat-linux/4.8.2/include/syslimits.h:7,
                     from /usr/lib/gcc/x86_64-redhat-linux/4.8.2/include/limits.h:34,
                     from /usr/lib64/glib-2.0/include/glibconfig.h:11,
                     from /usr/include/glib-2.0/glib/gtypes.h:34,
                     from /usr/include/glib-2.0/glib/galloca.h:34,
                     from /usr/include/glib-2.0/glib.h:32,
                     from /usr/include/glib-2.0/gobject/gbinding.h:30,
                     from /usr/include/glib-2.0/glib-object.h:25,
                     from ./glib-compat.h:24,
                     from ../config.h:201,
                     from spice-client-gtk-module.c:18:
    /usr/include/features.h:228:0: note: this is the location of the previous definition
     #  define _POSIX_C_SOURCE 200809L
     ^
    cc1: all warnings being treated as errors

diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index 8a16120..75962cf 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -450,14 +450,16 @@ spice-glib-enums.c: spice-glib-enums.h
 spice-widget-enums.c: spice-widget-enums.h
 
 spice-marshal.c: spice-marshal.txt
-	$(AM_V_GEN)echo "#include \"spice-marshal.h\"" > $@ && \
+	$(AM_V_GEN)echo "#include \"config.h\"" > $@ && \
+		echo "#include \"spice-marshal.h\"" > $@ && \
 		glib-genmarshal --body $< >> $@ || (rm -f $@ && exit 1)
 
 spice-marshal.h: spice-marshal.txt
 	$(AM_V_GEN)glib-genmarshal --header $< > $@ || (rm -f $@ && exit 1)
 
 spice-glib-enums.c: spice-channel.h channel-inputs.h spice-session.h
-	$(AM_V_GEN)glib-mkenums --fhead "#include <glib-object.h>\n" \
+	$(AM_V_GEN)glib-mkenums --fhead "#include \"config.h\"\n\n" \
+			--fhead "#include <glib-object.h>\n" \
 			--fhead "#include \"spice-glib-enums.h\"\n\n" \
 			--fprod "\n#include \"spice-session.h\"\n" \
 			--fprod "\n#include \"spice-channel.h\"\n" \
@@ -486,7 +488,8 @@ spice-glib-enums.h: spice-channel.h channel-inputs.h spice-session.h
 		$^ >  $@
 
 spice-widget-enums.c: spice-widget.h
-	$(AM_V_GEN)glib-mkenums --fhead "#include <glib-object.h>\n" \
+	$(AM_V_GEN)glib-mkenums --fhead "#include \"config.h\"\n\n" \
+			--fhead "#include <glib-object.h>\n" \
 			--fhead "#include \"spice-widget-enums.h\"\n\n" \
 			--fprod "\n#include \"spice-widget.h\"\n" \
 			--vhead "static const G at Type@Value _ at enum_name@_values[] = {" \
diff --git a/gtk/bio-gio.c b/gtk/bio-gio.c
index 22d58b6..cad904e 100644
--- a/gtk/bio-gio.c
+++ b/gtk/bio-gio.c
@@ -15,6 +15,7 @@
    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
+#include "config.h"
 
 #include <string.h>
 #include <glib.h>
diff --git a/gtk/channel-base.c b/gtk/channel-base.c
index 363dda5..77d339c 100644
--- a/gtk/channel-base.c
+++ b/gtk/channel-base.c
@@ -15,6 +15,8 @@
    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
+#include "config.h"
+
 #include "spice-client.h"
 #include "spice-common.h"
 
diff --git a/gtk/channel-cursor.c b/gtk/channel-cursor.c
index d33b90a..d7242a6 100644
--- a/gtk/channel-cursor.c
+++ b/gtk/channel-cursor.c
@@ -15,6 +15,8 @@
    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
+#include "config.h"
+
 #include "glib-compat.h"
 #include "spice-client.h"
 #include "spice-common.h"
diff --git a/gtk/channel-display-mjpeg.c b/gtk/channel-display-mjpeg.c
index 627aab4..2ad653e 100644
--- a/gtk/channel-display-mjpeg.c
+++ b/gtk/channel-display-mjpeg.c
@@ -15,6 +15,8 @@
    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
+#include "config.h"
+
 #include "spice-client.h"
 #include "spice-common.h"
 #include "spice-channel-priv.h"
diff --git a/gtk/channel-inputs.c b/gtk/channel-inputs.c
index a69dbe6..8a726e0 100644
--- a/gtk/channel-inputs.c
+++ b/gtk/channel-inputs.c
@@ -15,6 +15,8 @@
    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
+#include "config.h"
+
 #include "spice-client.h"
 #include "spice-common.h"
 #include "spice-channel-priv.h"
diff --git a/gtk/channel-main.c b/gtk/channel-main.c
index d44ac23..58f5d31 100644
--- a/gtk/channel-main.c
+++ b/gtk/channel-main.c
@@ -15,6 +15,8 @@
    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
+#include "config.h"
+
 #include <math.h>
 #include <spice/vd_agent.h>
 #include <common/rect.h>
diff --git a/gtk/channel-playback.c b/gtk/channel-playback.c
index bff5428..7789aa8 100644
--- a/gtk/channel-playback.c
+++ b/gtk/channel-playback.c
@@ -15,6 +15,8 @@
    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
+#include "config.h"
+
 #include "spice-client.h"
 #include "spice-common.h"
 #include "spice-channel-priv.h"
diff --git a/gtk/channel-port.c b/gtk/channel-port.c
index 5512713..ad85afd 100644
--- a/gtk/channel-port.c
+++ b/gtk/channel-port.c
@@ -15,6 +15,8 @@
    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
+#include "config.h"
+
 #include "spice-client.h"
 #include "spice-common.h"
 #include "spice-channel-priv.h"
diff --git a/gtk/channel-record.c b/gtk/channel-record.c
index 6b5e944..d4f47ba 100644
--- a/gtk/channel-record.c
+++ b/gtk/channel-record.c
@@ -15,6 +15,8 @@
    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
+#include "config.h"
+
 #include "spice-client.h"
 #include "spice-common.h"
 #include "spice-channel-priv.h"
diff --git a/gtk/decode-glz.c b/gtk/decode-glz.c
index e2626ef..b09de00 100644
--- a/gtk/decode-glz.c
+++ b/gtk/decode-glz.c
@@ -15,6 +15,8 @@
    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
+#include "config.h"
+
 #include <stdio.h>
 #include <stdbool.h>
 #include <inttypes.h>
diff --git a/gtk/decode-jpeg.c b/gtk/decode-jpeg.c
index 85976d0..cce7b53 100644
--- a/gtk/decode-jpeg.c
+++ b/gtk/decode-jpeg.c
@@ -15,6 +15,8 @@
    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
+#include "config.h"
+
 #include "decode.h"
 
 #ifdef WIN32
diff --git a/gtk/decode-zlib.c b/gtk/decode-zlib.c
index a692020..966fc16 100644
--- a/gtk/decode-zlib.c
+++ b/gtk/decode-zlib.c
@@ -15,6 +15,8 @@
    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
+#include "config.h"
+
 #include "decode.h"
 
 #ifndef __GNUC__
diff --git a/gtk/gio-coroutine.c b/gtk/gio-coroutine.c
index 9de9b54..d3ac16c 100644
--- a/gtk/gio-coroutine.c
+++ b/gtk/gio-coroutine.c
@@ -18,6 +18,7 @@
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
 */
+#include "config.h"
 
 #include "gio-coroutine.h"
 
diff --git a/gtk/glib-compat.c b/gtk/glib-compat.c
index 20cbc8b..f940e0a 100644
--- a/gtk/glib-compat.c
+++ b/gtk/glib-compat.c
@@ -16,6 +16,7 @@
    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
+#include "config.h"
 
 #include <string.h>
 
diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index 632a286..ace8b94 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -15,6 +15,8 @@
    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
+#include "config.h"
+
 #include "spice-client.h"
 #include "spice-common.h"
 #include "glib-compat.h"
diff --git a/gtk/spice-client.c b/gtk/spice-client.c
index 59f2918..4e7242f 100644
--- a/gtk/spice-client.c
+++ b/gtk/spice-client.c
@@ -15,6 +15,8 @@
    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
+#include "config.h"
+
 #include <glib.h>
 
 #include "spice-client.h"
diff --git a/gtk/spice-gtk-session.c b/gtk/spice-gtk-session.c
index eab7e2f..a9ce025 100644
--- a/gtk/spice-gtk-session.c
+++ b/gtk/spice-gtk-session.c
@@ -15,6 +15,7 @@
    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
+#include "config.h"
 
 #include <gtk/gtk.h>
 #include <spice/vd_agent.h>
diff --git a/gtk/spice-pulse.c b/gtk/spice-pulse.c
index c4241d0..32d6347 100644
--- a/gtk/spice-pulse.c
+++ b/gtk/spice-pulse.c
@@ -15,6 +15,8 @@
    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
+#include "config.h"
+
 #include "spice-pulse.h"
 #include "spice-common.h"
 #include "spice-session-priv.h"
diff --git a/gtk/spice-session.c b/gtk/spice-session.c
index 09556dc..7dea542 100644
--- a/gtk/spice-session.c
+++ b/gtk/spice-session.c
@@ -15,6 +15,8 @@
    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
+#include "config.h"
+
 #include <gio/gio.h>
 #include <glib.h>
 
diff --git a/gtk/spice-uri.c b/gtk/spice-uri.c
index 03b8c22..c379075 100644
--- a/gtk/spice-uri.c
+++ b/gtk/spice-uri.c
@@ -15,6 +15,7 @@
    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
+#include "config.h"
 
 #include <stdlib.h>
 #include <string.h>
diff --git a/gtk/spice-widget-cairo.c b/gtk/spice-widget-cairo.c
index e0fe1ed..107b0dc 100644
--- a/gtk/spice-widget-cairo.c
+++ b/gtk/spice-widget-cairo.c
@@ -15,13 +15,11 @@
   You should have received a copy of the GNU Lesser General Public
   License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
+#include "config.h"
+
 #include "spice-widget.h"
 #include "spice-widget-priv.h"
 
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
 /* Some compatibility defines to let us build on both Gtk2 and Gtk3 */
 #if GTK_CHECK_VERSION (2, 91, 0)
 
diff --git a/gtk/spice-widget-x11.c b/gtk/spice-widget-x11.c
index 05b8d56..f76bf2c 100644
--- a/gtk/spice-widget-x11.c
+++ b/gtk/spice-widget-x11.c
@@ -15,13 +15,11 @@
   You should have received a copy of the GNU Lesser General Public
   License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
+#include "config.h"
+
 #include "spice-widget.h"
 #include "spice-widget-priv.h"
 
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
 #ifdef HAVE_SYS_SHM_H
 #include <sys/shm.h>
 #endif
diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
index f5adf66..504a0b5 100644
--- a/gtk/spice-widget.c
+++ b/gtk/spice-widget.c
@@ -15,11 +15,9 @@
    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
-#include <math.h>
-
-#ifdef HAVE_CONFIG_H
 #include "config.h"
-#endif
+
+#include <math.h>
 
 #if HAVE_X11_XKBLIB_H
 #include <X11/XKBlib.h>
diff --git a/gtk/vmcstream.c b/gtk/vmcstream.c
index 8cef1b0..483dd5a 100644
--- a/gtk/vmcstream.c
+++ b/gtk/vmcstream.c
@@ -15,6 +15,8 @@
   You should have received a copy of the GNU Lesser General Public
   License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
+#include "config.h"
+
 #include <string.h>
 
 #include "vmcstream.h"
diff --git a/gtk/vncdisplaykeymap.c b/gtk/vncdisplaykeymap.c
index 7162d63..22c6b07 100644
--- a/gtk/vncdisplaykeymap.c
+++ b/gtk/vncdisplaykeymap.c
@@ -7,6 +7,7 @@
  * published by the Free Software Foundation.
  *
  */
+#include "config.h"
 
 #include <gtk/gtk.h>
 #include <gdk/gdk.h>


More information about the Spice-commits mailing list