updates.
authorPekka Riikonen <priikone@silcnet.org>
Wed, 25 Jul 2001 20:14:17 +0000 (20:14 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Wed, 25 Jul 2001 20:14:17 +0000 (20:14 +0000)
CHANGES
apps/irssi/src/core/expandos.c
apps/irssi/src/core/modules.c
apps/irssi/src/fe-common/core/themes.c
apps/irssi/src/silc/core/client_ops.c
lib/silcclient/client.c
lib/silcclient/silcapi.h

diff --git a/CHANGES b/CHANGES
index c25fa149d2b057b5cfe3d73a73b8ec99308c8026..71f4185b7969ba9fb396d16aff1ecb58481e7671 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -4,6 +4,26 @@ Wed Jul 25 18:43:54 EEST 2001  Pekka Riikonen <priikone@silcnet.org>
          does not have it defined.  Affected files are
          lib/silcutil/[unix/win32]/silc[unix/win32]net.c.
 
+       * Fixed buffer overflow from Irssi SILC Client.  Affected
+         file irssi/src/fe-common/core/themes.c.
+
+       * Fixed double free in client library in the file
+         lib/silcclient/client.c when disconnecting from server.
+
+       * Applied double free patch from cras to Irssi SILC client.
+         Affected files irssi/src/core/[modules/expandos].c
+
+       * Fixed the disconnection handling to Irssi SILC Client.
+         The application must call silc_client_close_connection
+         in ops->connect client operation in case of failure of
+         the connection.  Affected file is
+         irssi/src/silc/core/client_ops.c.
+
+       * Do not set sock->protocol to NULL in the function
+         silc_client_close_connection after executing the protocol's
+         final callback since the sock might not be valid anymore.
+         Affected file lib/silcclient/client.c.
+
 Wed Jul 25 16:04:35 EEST 2001  Pekka Riikonen <priikone@silcnet.org>
 
        * Do not enable SILC_THREADS if the linking with libpthread
index e6572316159eda904988ca33e574c5d9a661f185..21ebae6b8b8ab020ebcf798cfd9c7d0a16bf8008 100644 (file)
@@ -144,8 +144,8 @@ void expando_destroy(const char *key, EXPANDO_FUNC func)
        } else if (g_hash_table_lookup_extended(expandos, key, &origkey,
                                                (gpointer *) &rec)) {
                if (rec->func == func) {
-                       g_free(origkey);
                        g_hash_table_remove(expandos, key);
+                       g_free(origkey);
                        g_free(rec);
                }
        }
index 4bcbbe75ae113955f7eda9670c09b783e7dc01ee..9797a059c91e6b444cbb3831802d0fae6388b06b 100644 (file)
@@ -405,7 +405,7 @@ void module_unload(MODULE_REC *module)
 
 static void uniq_get_modules(char *key, void *value, GSList **list)
 {
-        *list = g_slist_append(*list, key);
+        *list = g_slist_append(*list, g_strdup(key));
 }
 
 void modules_init(void)
@@ -434,6 +434,7 @@ void modules_deinit(void)
 
        while (list != NULL) {
                module_uniq_destroy(list->data);
+               g_free(list->data);
                list = g_slist_remove(list, list->data);
        }
 
index ca26f68f2b882e02c480f20ae7692203a61e606c..ab768ccbe53f8c34e7a0b65951b3709731ae9414 100644 (file)
@@ -128,9 +128,9 @@ static const char *fgcolorformats = "nkrgybmpcwKRGYBMPCW";
 static const char *bgcolorformats = "n01234567";
 
 #define IS_FGCOLOR_FORMAT(c) \
-        ((c) != '\0' && strchr(fgcolorformats, c) != NULL)
+        ((c) != '\0' && strchr(fgcolorformats, (c)) != NULL)
 #define IS_BGCOLOR_FORMAT(c) \
-        ((c) != '\0' && strchr(bgcolorformats, c) != NULL)
+        ((c) != '\0' && strchr(bgcolorformats, (c)) != NULL)
 
 /* append "variable" part in $variable, ie. not the contents of the variable */
 static void theme_format_append_variable(GString *str, const char **format)
@@ -413,9 +413,9 @@ static char *theme_format_compress_colors(THEME_REC *theme, const char *format)
                        if (IS_OLD_FORMAT(*format, last_fg, last_bg)) {
                                /* active color set again */
                        } else if (IS_FGCOLOR_FORMAT(*format) &&
-                                  (*format != 'n' || format[2] == 'n') &&
                                   format[1] == '%' &&
-                                  IS_FGCOLOR_FORMAT(format[2])) {
+                                  IS_FGCOLOR_FORMAT(format[2]) &&
+                                  (*format != 'n' || format[2] == 'n')) {
                                /* two fg colors in a row. bg colors are
                                   so rare that we don't bother checking
                                   them */
index 103ccfd6ebfe2cdb2e48013e97709974a8e3e050..c92d9836ccbe8c0c5dd16dfd2cd0b9a8a02f7ee5 100644 (file)
@@ -188,6 +188,11 @@ void silc_connect(SilcClient client, SilcClientConnection conn, int success)
 {
   SILC_SERVER_REC *server = conn->context;
 
+  if (!server && !success) {
+    silc_client_close_connection(client, NULL, conn);
+    return;
+  }
+
   if (success) {
     server->connected = TRUE;
     signal_emit("event connected", 1, server);
index 09249d05a39e62578c116071b88dec2ad24d1dc9..42765c942a98dcdfbf3686127611284134e73a10 100644 (file)
@@ -322,6 +322,12 @@ int silc_client_start_key_exchange(SilcClient client,
   /* Allocate new socket connection object */
   silc_socket_alloc(fd, SILC_SOCKET_TYPE_SERVER, (void *)conn, &conn->sock);
 
+  /* Sometimes when doing quick reconnects the new socket may be same as
+     the old one and there might be pending stuff for the old socket. 
+     If new one is same then those pending sutff might cause problems.
+     Make sure they do not do that. */
+  silc_schedule_task_del_by_fd(client->schedule, fd);
+
   conn->nickname = strdup(client->username);
   conn->sock->hostname = conn->remote_host;
   conn->sock->ip = strdup(conn->remote_host);
@@ -1177,7 +1183,6 @@ void silc_client_close_connection(SilcClient client,
        SILC_PROTOCOL_CLIENT_CONNECTION_AUTH) {
       sock->protocol->state = SILC_PROTOCOL_STATE_ERROR;
       silc_protocol_execute_final(sock->protocol, client->schedule);
-      sock->protocol = NULL;
       /* The application will recall this function with these protocols
         (the ops->connect client operation). */
       return;
@@ -1230,11 +1235,9 @@ void silc_client_close_connection(SilcClient client,
     if (conn->server_cache)
       silc_idcache_del_all(conn->server_cache);
 
-    /* Free data */
+    /* Free data (my ID is freed in above silc_client_del_client) */
     if (conn->remote_host)
       silc_free(conn->remote_host);
-    if (conn->local_id)
-      silc_free(conn->local_id);
     if (conn->local_id_data)
       silc_free(conn->local_id_data);
     if (conn->send_key)
index 91de9b63fef9bc7ca3eef10e5e6fd7fc4fe150a9..6add5c0b49afde1b5917065631280e5ffde6a323 100644 (file)
@@ -268,7 +268,9 @@ typedef struct {
 
   /* Called to indicate that connection was either successfully established
      or connecting failed.  This is also the first time application receives
-     the SilcClientConnection objecet which it should save somewhere. */
+     the SilcClientConnection objecet which it should save somewhere.
+     If the `success' is FALSE the application must always call the function
+     silc_client_close_connection. */
   void (*connect)(SilcClient client, SilcClientConnection conn, int success);
 
   /* Called to indicate that connection was disconnected to the server. */