if (server->router_conn && server->router_conn->sock == stream &&
!server->router && server->standalone) {
+ if (idata->sconn && idata->sconn->callback)
+ (*idata->sconn->callback)(server, NULL, idata->sconn->callback_context);
silc_server_create_connections(server);
+ silc_server_free_sock_user_data(server, stream, NULL);
} else {
/* If backup disconnected then mark that resuming will not be allowed */
if (server->server_type == SILC_ROUTER && !server->backup_router &&
if (!silc_packet_stream_is_valid(stream))
return;
+ /* In case we get here many times, register only one timeout */
+ silc_schedule_task_del_by_all(server->schedule, 0,
+ silc_server_packet_error_timeout, stream);
+
+ /* Close connection with random timeout */
silc_schedule_task_add_timeout(server->schedule,
silc_server_packet_error_timeout, stream,
- silc_rng_get_byte(server->rng) % 5, 0);
+ silc_rng_get_byte(server->rng) % 10, 0);
}
/* Packet stream callbacks */
#define SILC_IS_LOCAL(entry) \
(((SilcIDListData)entry)->status & SILC_IDLIST_STATUS_LOCAL)
-/* Registers generic task for file descriptor for reading from network and
- writing to network. As being generic task the actual task is allocated
- only once and after that the same task applies to all registered fd's. */
-#define SILC_REGISTER_CONNECTION_FOR_IO(fd) \
-do { \
- silc_schedule_task_add(server->schedule, (fd), \
- silc_server_packet_process, \
- context, 0, 0, \
- SILC_TASK_GENERIC, \
- SILC_TASK_PRI_NORMAL); \
-} while(0)
-
-#define SILC_SET_CONNECTION_FOR_INPUT(s, fd) \
-do { \
- silc_schedule_set_listen_fd((s), (fd), SILC_TASK_READ, FALSE); \
-} while(0)
-
-#define SILC_SET_CONNECTION_FOR_OUTPUT(s, fd) \
-do { \
- silc_schedule_set_listen_fd((s), (fd), (SILC_TASK_READ | SILC_TASK_WRITE), \
- FALSE); \
-} while(0)
-
#define SILC_OPER_STATS_UPDATE(c, type, mod) \
do { \
if ((c)->mode & (mod)) { \
/* Get packet length and full packet length with padding */
SILC_PACKET_LENGTH(header, packetlen, paddedlen);
+ /* Padding sanity checks */
+ if (cipher && (paddedlen % block_len) != 0) {
+ SILC_LOG_DEBUG(("Packet length %d not multiple by cipher block length",
+ paddedlen));
+ silc_mutex_unlock(stream->lock);
+ SILC_PACKET_CALLBACK_ERROR(stream, SILC_PACKET_ERR_MALFORMED);
+ silc_mutex_lock(stream->lock);
+ memset(tmp, 0, sizeof(tmp));
+ goto out;
+ }
+
if (silc_buffer_len(inbuf) < paddedlen + ivlen + mac_len) {
SILC_LOG_DEBUG(("Received partial packet, waiting for the rest "
"(%d bytes)",