X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=blobdiff_plain;f=apps%2Fsilcd%2Fserver_util.c;h=dead873a6d250037bff3b3c9a91a585e9a4acc0a;hp=790979cdf208808b9f5ec6706291010420d357c4;hb=382d15d447b7a95390decfa783836ae4fe255b3d;hpb=bbc2071bac65ded8d5bc07831d768de254c55842 diff --git a/apps/silcd/server_util.c b/apps/silcd/server_util.c index 790979cd..dead873a 100644 --- a/apps/silcd/server_util.c +++ b/apps/silcd/server_util.c @@ -42,7 +42,9 @@ silc_server_remove_clients_channels(SilcServer server, if (!client) return; - SILC_LOG_DEBUG(("Remove client from all channels")); + SILC_LOG_DEBUG(("Remove client %s from all channels", + client->nickname ? client->nickname : + (unsigned char *)"")); if (silc_hash_table_find(clients, client, NULL, NULL)) silc_hash_table_del(clients, client); @@ -1513,7 +1515,7 @@ void silc_server_kill_client(SilcServer server, /* Remove the client from all channels. This generates new keys to the channels as well. */ silc_server_remove_from_channels(server, NULL, remote_client, FALSE, - NULL, TRUE); + NULL, TRUE, TRUE); /* Remove the client entry, If it is locally connected then we will also disconnect the client here */ @@ -1723,7 +1725,7 @@ bool silc_server_inviteban_match(SilcServer server, SilcHashTable list, unsigned char *tmp = NULL; SilcUInt32 len = 0, t; SilcHashTableList htl; - SilcBuffer entry; + SilcBuffer entry, idp = NULL; bool ret = FALSE; if (type < 1 || type > 3 || !check) @@ -1740,10 +1742,11 @@ bool silc_server_inviteban_match(SilcServer server, SilcHashTable list, return FALSE; } if (type == 3) { - tmp = silc_id_id2str(check, SILC_ID_CLIENT); - if (!tmp) + idp = silc_id_payload_encode(check, SILC_ID_CLIENT); + if (!idp) return FALSE; - len = silc_id_get_len(check, SILC_ID_CLIENT); + tmp = idp->data; + len = idp->len; } /* Compare the list */ @@ -1763,10 +1766,18 @@ bool silc_server_inviteban_match(SilcServer server, SilcHashTable list, } silc_hash_table_list_reset(&htl); - silc_free(tmp); + if (!idp) + silc_free(tmp); + silc_buffer_free(idp); return ret; } +static void silc_server_inviteban_dummy_dest(void *key, void *context, + void *user_context) +{ + /* Nothing */ +} + /* Process invite or ban information */ void silc_server_inviteban_process(SilcServer server, SilcHashTable list, @@ -1792,7 +1803,8 @@ void silc_server_inviteban_process(SilcServer server, SilcHashTable list, char *string = NULL; silc_hash_table_find(list, (void *)1, NULL, (void **)&string); - silc_hash_table_del(list, (void *)1); + silc_hash_table_del_ext(list, (void *)1, NULL, NULL, NULL, NULL, + silc_server_inviteban_dummy_dest, NULL); if (!string) string = silc_calloc(len + 2, sizeof(*string)); else @@ -1854,7 +1866,7 @@ void silc_server_inviteban_process(SilcServer server, SilcHashTable list, } /* Delete information to invite list */ - if (action && list) { + if (action == 0x01 && list) { /* Now delete the arguments from invite list */ tmp = silc_argument_get_first_arg(args, &type, &len); while (tmp) { @@ -1864,10 +1876,8 @@ void silc_server_inviteban_process(SilcServer server, SilcHashTable list, char *string = NULL, *start, *end, *n; if (silc_hash_table_find(list, (void *)1, NULL, (void **)&string)) { - silc_hash_table_del(list, (void *)1); - if (!strncmp(string, tmp, strlen(string) - 1)) { - silc_free(string); + silc_hash_table_del(list, (void *)1); string = NULL; } else { start = strstr(string, tmp); @@ -1876,7 +1886,7 @@ void silc_server_inviteban_process(SilcServer server, SilcHashTable list, n = silc_calloc(strlen(string) - len, sizeof(*n)); strncat(n, string, start - string); strncat(n, end + 1, ((string + strlen(string)) - end) - 1); - silc_free(string); + silc_hash_table_del(list, (void *)1); string = n; } } @@ -1894,7 +1904,6 @@ void silc_server_inviteban_process(SilcServer server, SilcHashTable list, while (silc_hash_table_get(&htl, (void **)&type, (void **)&tmp2)) { if (type == 2 && !memcmp(tmp2->data, tmp, len)) { silc_hash_table_del_by_context(list, (void *)2, tmp2); - silc_buffer_free(tmp2); break; } } @@ -1906,9 +1915,8 @@ void silc_server_inviteban_process(SilcServer server, SilcHashTable list, /* Delete from the invite list */ silc_hash_table_list(list, &htl); while (silc_hash_table_get(&htl, (void **)&type, (void **)&tmp2)) { - if (type == 2 && !memcmp(tmp2->data, tmp, len)) { - silc_hash_table_del_by_context(list, (void *)2, tmp2); - silc_buffer_free(tmp2); + if (type == 3 && !memcmp(tmp2->data, tmp, len)) { + silc_hash_table_del_by_context(list, (void *)3, tmp2); break; } } @@ -1919,3 +1927,23 @@ void silc_server_inviteban_process(SilcServer server, SilcHashTable list, } } } + +/* Destructor for invite or ban list entrys */ + +void silc_server_inviteban_destruct(void *key, void *context, + void *user_context) +{ + switch ((SilcUInt32)key) { + case 1: + /* Invite string */ + silc_free(context); + break; + case 2: + case 3: + /* Public key/Channel ID SilcBuffer */ + silc_buffer_free(context); + break; + default: + break; + } +}