[gtk-vnc] Misc code fixes to vncconnectionc.



commit 20719fedb7dc601e9e6915327ad6b67d834ad6a6
Author: Daniel P. Berrange <berrange redhat com>
Date:   Fri Feb 10 17:01:12 2012 +0000

    Misc code fixes to vncconnectionc.
    
     - Add default cases for switch statements
     - Replace #if with #ifdef for DEBUG check
     - Reduce excessive stack usage

 src/vncconnection.c |   26 +++++++++++++++++++++-----
 1 files changed, 21 insertions(+), 5 deletions(-)
---
diff --git a/src/vncconnection.c b/src/vncconnection.c
index 47d24d4..b65eb9c 100644
--- a/src/vncconnection.c
+++ b/src/vncconnection.c
@@ -522,6 +522,9 @@ static gboolean do_vnc_connection_emit_main_context(gpointer opaque)
                       signals[data->signum],
                       0);
         break;
+
+    default:
+        g_warn_if_reached();
     }
 
     coroutine_yieldto(data->caller, NULL);
@@ -685,17 +688,22 @@ static int vnc_connection_read_sasl(VncConnection *conn)
     //VNC_DEBUG("Read SASL %p size %d offset %d", priv->saslDecoded,
     //           priv->saslDecodedLength, priv->saslDecodedOffset);
     if (priv->saslDecoded == NULL) {
-        char encoded[8192];
-        int encodedLen = sizeof(encoded);
+        char *encoded;
+        int encodedLen;
         int err, ret;
 
+        encodedLen = 8192;
+        encoded = g_new0(char, encodedLen);
+
         ret = vnc_connection_read_wire(conn, encoded, encodedLen);
         if (ret < 0) {
+            g_free(encoded);
             return ret;
         }
 
         err = sasl_decode(priv->saslconn, encoded, ret,
                           &priv->saslDecoded, &priv->saslDecodedLength);
+        g_free(encoded);
         if (err != SASL_OK) {
             VNC_DEBUG("Failed to decode SASL data %s",
                       sasl_errstring(err, NULL, NULL));
@@ -2037,15 +2045,19 @@ static void vnc_connection_zrle_update_tile_blit(VncConnection *conn,
                                                  guint16 width, guint16 height)
 {
     VncConnectionPrivate *priv = conn->priv;
-    guint8 blit_data[4 * 64 * 64];
+    guint8 *blit_data;
     int i, bpp;
 
+    blit_data = g_new0(guint8, 4*64*64);
+
     bpp = vnc_connection_pixel_size(conn);
 
     for (i = 0; i < width * height; i++)
         vnc_connection_read_cpixel(conn, blit_data + (i * bpp));
 
     vnc_framebuffer_blt(priv->fb, blit_data, width * bpp, x, y, width, height);
+
+    g_free(blit_data);
 }
 
 static guint8 vnc_connection_read_zrle_pi(VncConnection *conn, int palette_size)
@@ -2901,6 +2913,8 @@ static gboolean do_vnc_connection_audio_action(gpointer opaque)
     case 2:
         vnc_audio_playback_data(priv->audio, priv->audio_sample);
         break;
+    default:
+        g_warn_if_reached();
     }
 
     coroutine_yieldto(data->caller, NULL);
@@ -3564,6 +3578,9 @@ vnc_connection_gather_sasl_credentials(VncConnection *conn,
             interact[ninteract].len = strlen(priv->cred_password);
             //VNC_DEBUG("Gather Password %s", priv->cred_password);
             break;
+
+        default:
+            g_warn_if_reached();
         }
     }
 
@@ -3607,7 +3624,6 @@ vnc_connection_gather_sasl_credentials(VncConnection *conn,
  */
 
 #define SASL_MAX_MECHLIST_LEN 300
-#define SASL_MAX_MECHNAME_LEN 100
 #define SASL_MAX_DATA_LEN (1024 * 1024)
 
 /* Perform the SASL authentication process
@@ -4247,7 +4263,7 @@ static gboolean vnc_connection_perform_auth_vencrypt(VncConnection *conn)
     if (!vnc_connection_gather_credentials(conn))
         return FALSE;
 
-#if !DEBUG
+#ifndef DEBUG
     if (priv->auth_subtype == VNC_CONNECTION_AUTH_VENCRYPT_PLAIN) {
         VNC_DEBUG("Cowardly refusing to transmit plain text password");
         return FALSE;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]