silc_schedule_one(client->schedule, 0);
}
-static void silc_client_entry_destructor(SilcIDCache cache,
- SilcIDCacheEntry entry)
-{
- silc_free(entry->name);
-}
-
/* Allocates and adds new connection to the client. This adds the allocated
connection to the connection table and returns a pointer to it. A client
can have multiple connections to multiple servers. Every connection must
conn->remote_port = port;
conn->context = context;
conn->internal->client_cache =
- silc_idcache_alloc(0, SILC_ID_CLIENT, silc_client_entry_destructor,
- FALSE, FALSE);
+ silc_idcache_alloc(0, SILC_ID_CLIENT, NULL, NULL, FALSE, TRUE);
conn->internal->channel_cache = silc_idcache_alloc(0, SILC_ID_CHANNEL, NULL,
- FALSE, FALSE);
+ NULL, FALSE, TRUE);
conn->internal->server_cache = silc_idcache_alloc(0, SILC_ID_SERVER, NULL,
- FALSE, FALSE);
+ NULL, FALSE, TRUE);
conn->internal->pending_commands = silc_dlist_init();
conn->internal->ftp_sessions = silc_dlist_init();
const SilcBufferStruct packet;
int block_len;
SilcUInt32 sequence = 0;
+ int src_id_allocated = FALSE;
if (!sock)
return;
} else {
packetdata.src_id = silc_calloc(SILC_ID_CLIENT_LEN, sizeof(unsigned char));
packetdata.src_id_len = SILC_ID_CLIENT_LEN;
+ src_id_allocated = TRUE;
}
packetdata.src_id_type = SILC_ID_CLIENT;
if (dst_id) {
if (!silc_packet_assemble(&packetdata, client->rng, cipher, hmac, sock,
data, data_len, (const SilcBuffer)&packet)) {
SILC_LOG_ERROR(("Error assembling packet"));
- return;
+ goto out;
}
/* Encrypt the packet */
/* Now actually send the packet */
silc_client_packet_send_real(client, sock, force_send);
+
+ out:
+ if (src_id_allocated && packetdata.src_id)
+ silc_free(packetdata.src_id);
+ if (packetdata.dst_id)
+ silc_free(packetdata.dst_id);
}
/* Packet sending routine for application. This is the only routine that
SilcClientConnection conn = (SilcClientConnection)sock->user_data;
int connecting = FALSE;
SilcClientID *client_id = silc_id_payload_get_id(idp);
+ char *nickname;
if (!conn->local_entry)
connecting = TRUE;
NULL, NULL, NULL,
TRUE);
- /* Put it to the ID cache */
- silc_idcache_add(conn->internal->client_cache,
- strdup(conn->nickname), conn->local_id,
+ /* Normalize nickname */
+ nickname = silc_identifier_check(conn->nickname, strlen(conn->nickname),
+ SILC_STRING_UTF8, 128, NULL);
+ if (!nickname)
+ return;
+
+ /* Put it to the ID cache */
+ silc_idcache_add(conn->internal->client_cache, nickname, conn->local_id,
(void *)conn->local_entry, 0, NULL);
if (connecting) {