+Fri Jun 29 20:05:25 EEST 2001 Pekka Riikonen <priikone@silcnet.org>
+
+ * Assure that sock->user_data is not NULL in the function
+ silc_server_packet_send in silcd/packet_send.c.
+
+ * Disconnect the remote connection if it could not be added
+ to any ID lists in the server. The affected file is
+ silcd/server.c.
+
+ * Check in silc_server_packet_send[_real/dest] that the
+ socket is not disconnecting and ignore the data if it is.
+ Affected file silcd/packet_send.c.
+
+ * Define inline to __inline on native WIN32 compilation.
+ Affected file includes/silcwin32.h.
+
+ * Added some explicit type casts for inline code since MSVC
+ require them. Affected files lib/silcutil/silcbuffer.h,
+ lib/trq/silcdlist.h and lib/trq/silclist.h.
+
+ * Print warning in log files from now on if the packet
+ decryption fails. Affected file silcd/server.c.
+
Thu Jun 28 21:30:39 EEST 2001 Pekka Riikonen <priikone@silcnet.org>
* Changed the `say' client operation's interface to accept
packet_send.c
- Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
+ Author: Pekka Riikonen <priikone@silcnet.org>
Copyright (C) 1997 - 2001 Pekka Riikonen
{
int ret;
+ /* If disconnecting, ignore the data */
+ if (SILC_IS_DISCONNECTING(sock))
+ return -1;
+
/* If rekey protocol is active we must assure that all packets are
sent through packet queue. */
if (SILC_SERVER_IS_REKEY(sock))
if (!sock)
return;
+ /* If disconnecting, ignore the data */
+ if (SILC_IS_DISCONNECTING(sock))
+ return;
+
/* Get data used in the packet sending, keys and stuff */
switch(sock->type) {
case SILC_SOCKET_TYPE_CLIENT:
- dst_id = ((SilcClientEntry)sock->user_data)->id;
- dst_id_type = SILC_ID_CLIENT;
+ if (sock->user_data) {
+ dst_id = ((SilcClientEntry)sock->user_data)->id;
+ dst_id_type = SILC_ID_CLIENT;
+ }
break;
case SILC_SOCKET_TYPE_SERVER:
case SILC_SOCKET_TYPE_ROUTER:
- dst_id = ((SilcServerEntry)sock->user_data)->id;
- dst_id_type = SILC_ID_SERVER;
+ if (sock->user_data) {
+ dst_id = ((SilcServerEntry)sock->user_data)->id;
+ dst_id_type = SILC_ID_SERVER;
+ }
break;
default:
break;
unsigned char *dst_id_data = NULL;
uint32 dst_id_len = 0;
+ /* If disconnecting, ignore the data */
+ if (SILC_IS_DISCONNECTING(sock))
+ return;
+
SILC_LOG_DEBUG(("Sending packet, type %d", type));
/* Get data used in the packet sending, keys and stuff */
server.c
- Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
+ Author: Pekka Riikonen <priikone@silcnet.org>
Copyright (C) 1997 - 2001 Pekka Riikonen
return;
}
- sock->type = ctx->conn_type;
- switch(sock->type) {
+ switch(ctx->conn_type) {
case SILC_SOCKET_TYPE_CLIENT:
{
SilcClientEntry client;
if (!client) {
SILC_LOG_ERROR(("Could not add new client to cache"));
silc_free(sock->user_data);
- break;
+ silc_server_disconnect_remote(server, sock,
+ "Server closed connection: "
+ "Authentication failed");
+ server->stat.auth_failures++;
+ goto out;
}
/* Statistics */
{
SilcServerEntry new_server;
SilcServerConfigSectionServerConnection *conn =
- sock->type == SILC_SOCKET_TYPE_SERVER ? ctx->sconfig : ctx->rconfig;
+ ctx->conn_type == SILC_SOCKET_TYPE_SERVER ?
+ ctx->sconfig : ctx->rconfig;
SILC_LOG_DEBUG(("Remote host is %s",
- sock->type == SILC_SOCKET_TYPE_SERVER ?
+ ctx->conn_type == SILC_SOCKET_TYPE_SERVER ?
"server" : "router"));
SILC_LOG_INFO(("Connection from %s (%s) is %s", sock->hostname,
- sock->ip, sock->type == SILC_SOCKET_TYPE_SERVER ?
+ sock->ip, ctx->conn_type == SILC_SOCKET_TYPE_SERVER ?
"server" : "router"));
/* Add the server into server cache. The server name and Server ID
are router. */
new_server =
silc_idlist_add_server(server->local_list, NULL,
- sock->type == SILC_SOCKET_TYPE_SERVER ?
+ ctx->conn_type == SILC_SOCKET_TYPE_SERVER ?
SILC_SERVER : SILC_ROUTER, NULL,
- sock->type == SILC_SOCKET_TYPE_SERVER ?
+ ctx->conn_type == SILC_SOCKET_TYPE_SERVER ?
server->id_entry : NULL, sock);
if (!new_server) {
SILC_LOG_ERROR(("Could not add new server to cache"));
silc_free(sock->user_data);
- break;
+ silc_server_disconnect_remote(server, sock,
+ "Server closed connection: "
+ "Authentication failed");
+ server->stat.auth_failures++;
+ goto out;
}
/* Statistics */
- if (sock->type == SILC_SOCKET_TYPE_SERVER)
+ if (ctx->conn_type == SILC_SOCKET_TYPE_SERVER)
server->stat.my_servers++;
else
server->stat.my_routers++;
/* Check whether this connection is to be our primary router connection
if we dont' already have the primary route. */
- if (server->standalone && sock->type == SILC_SOCKET_TYPE_ROUTER) {
+ if (server->standalone && ctx->conn_type == SILC_SOCKET_TYPE_ROUTER) {
if (silc_server_config_is_primary_route(server->config) &&
!conn->initiator)
break;
break;
}
+ sock->type = ctx->conn_type;
+
/* Add the common data structure to the ID entry. */
if (id_entry)
silc_idlist_add_data(id_entry, (SilcIDListData)sock->user_data);
silc_server_perform_heartbeat,
server->timeout_queue);
+ out:
silc_task_unregister_by_callback(server->timeout_queue,
silc_server_failure_callback);
silc_protocol_free(protocol);
idata ? idata->hmac_receive : NULL,
packet->buffer, packet,
silc_server_packet_decrypt_check, parse_ctx);
- if (ret < 0)
+ if (ret < 0) {
+ SILC_LOG_WARNING(("Packet decryption failed for connection "
+ "%s:%d [%s]", sock->hostname, sock->port,
+ (sock->type == SILC_SOCKET_TYPE_UNKNOWN ? "Unknown" :
+ sock->type == SILC_SOCKET_TYPE_CLIENT ? "Client" :
+ sock->type == SILC_SOCKET_TYPE_SERVER ? "Server" :
+ "Router")));
goto out;
+ }
if (ret == 0) {
/* Parse the packet. Packet type is returned. */