From 1bf495487aa2f5f4b12e03c6be55a2baec21a09e Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Wed, 25 Jul 2001 20:14:17 +0000 Subject: [PATCH] updates. --- CHANGES | 20 ++++++++++++++++++++ apps/irssi/src/core/expandos.c | 2 +- apps/irssi/src/core/modules.c | 3 ++- apps/irssi/src/fe-common/core/themes.c | 8 ++++---- apps/irssi/src/silc/core/client_ops.c | 5 +++++ lib/silcclient/client.c | 11 +++++++---- lib/silcclient/silcapi.h | 4 +++- 7 files changed, 42 insertions(+), 11 deletions(-) diff --git a/CHANGES b/CHANGES index c25fa149..71f4185b 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,26 @@ Wed Jul 25 18:43:54 EEST 2001 Pekka Riikonen 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 * Do not enable SILC_THREADS if the linking with libpthread diff --git a/apps/irssi/src/core/expandos.c b/apps/irssi/src/core/expandos.c index e6572316..21ebae6b 100644 --- a/apps/irssi/src/core/expandos.c +++ b/apps/irssi/src/core/expandos.c @@ -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); } } diff --git a/apps/irssi/src/core/modules.c b/apps/irssi/src/core/modules.c index 4bcbbe75..9797a059 100644 --- a/apps/irssi/src/core/modules.c +++ b/apps/irssi/src/core/modules.c @@ -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); } diff --git a/apps/irssi/src/fe-common/core/themes.c b/apps/irssi/src/fe-common/core/themes.c index ca26f68f..ab768ccb 100644 --- a/apps/irssi/src/fe-common/core/themes.c +++ b/apps/irssi/src/fe-common/core/themes.c @@ -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 */ diff --git a/apps/irssi/src/silc/core/client_ops.c b/apps/irssi/src/silc/core/client_ops.c index 103ccfd6..c92d9836 100644 --- a/apps/irssi/src/silc/core/client_ops.c +++ b/apps/irssi/src/silc/core/client_ops.c @@ -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); diff --git a/lib/silcclient/client.c b/lib/silcclient/client.c index 09249d05..42765c94 100644 --- a/lib/silcclient/client.c +++ b/lib/silcclient/client.c @@ -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) diff --git a/lib/silcclient/silcapi.h b/lib/silcclient/silcapi.h index 91de9b63..6add5c0b 100644 --- a/lib/silcclient/silcapi.h +++ b/lib/silcclient/silcapi.h @@ -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. */ -- 2.24.0