Code auditing weekend results and fixes committing.
[silc.git] / CHANGES
diff --git a/CHANGES b/CHANGES
index 9003d86fc38cf5dee940ee92e6ad236e0d01e590..c61205c7f785ac2b10861a325bfa9e8da73ce6b0 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,518 @@
+Sat Feb 10 21:13:45 EET 2001  Pekka Riikonen <priikone@poseidon.pspt.fi>
+
+       * A big code auditing weekend happening.  Auditing code for 
+         obvious mistakes, bugs and errors.  Also, removing any code
+         that is obsolete.
+
+         Removed files for being obsolete:
+
+         o lib/silcutil/silcbuffer.c (the buffer interface is entirely in
+         inline in the file lib/silcutil/silcbuffer.h)
+
+         o lib/silcutil/silcbufutil.c (the header has inline versions)
+
+         Changed code to fix possible error conditions:
+
+         o The buffer formatting routines now check that the destination
+         buffer really has enough space to add the data.  This applies for
+         both buffer formatting and unformatting 
+         (lib/silcutil/silcbuffmt.[ch]).  Also, the entire buffer
+         unformatting was changed to accomodate following rules: 
+         XXX_*STRING_ALLOC will allocate space for the data into the pointer
+         sent to the function while XXX_*STRING will not allocate or copy 
+         the data into the buffer.  Instead it sets the pointer from the
+         buffer into the pointer sent as argument (XXX_*STRING used to
+         require that the pointer must be allocated already).  This change
+         makes this whole thing a bit more consistent and more optimized
+         (note that the data returned in the unformatting with XXX_*STRING
+         must not be freed now).  The routines return now -1 on error.
+
+         o Tried to find all code that use buffer_format and buffer_unformat
+         and added return value checking to prevent formatting and
+         especially unformatting errors and possible subsequent fatal
+         errors.
+
+         o Changed ske->x and ske->KEY to mallocated pointers in
+         lib/silcske/silcske.h.  Fixed possible data and memory leak.
+
+         o Added return value checking to all *_parse* functions.  Fixed
+         many memory leaks as well.
+
+         o Added length argument to silc_id_str2id in lib/silccore/id.[ch]
+         so that buffer overflows would not happen.  All code now also
+         checks the return value as it can fail.
+
+Mon Feb  5 20:08:30 EET 2001  Pekka Riikonen <priikone@poseidon.pspt.fi>
+
+       * Added reconnection support to server if the normal server looses
+         its connection to the router (for example if router is rebooted).
+         The server performs normal reconnection strategy implemented
+         to the server.  Affected file silcd/server.c.
+
+Sun Feb  4 13:18:32 EET 2001  Pekka Riikonen <priikone@poseidon.pspt.fi>
+
+       * Added new packet type SILC_PACKET_SET_MODE that is used to
+         distribute the information about changed modes (for clients,
+         channels and clients channel modes) to all routers in the
+         network.  Updated the protocol specification accordingly.
+
+         Added functions into silcd/packet_send.c and 
+         silcd/packet_receive.c: silc_server_send_set_mode, 
+         silc_server_set_mode.
+
+         Added new files silcmode.[ch] into lib/silccore that implements
+         the encoding and decoding of Set Mode Payload.  Added new type
+         SilcSetModePayload.  Moved the definitions of different modes
+         from lib/silccore/silcchannel.h into lib/silccore/silcmode.h.
+
+Sat Feb  3 15:44:54 EET 2001  Pekka Riikonen <priikone@poseidon.pspt.fi>
+
+       * Oops, a little mistake in server's connection authentication 
+         protocol.  The protocol is not ended with FAILURE but with
+         SUCCESS if the authentication is Ok. :)  Affected file is
+         silcd/protocol.c.
+
+       * Implemented NICK_CHANGE notify handling in server in the file
+         silcd/packet_receive.c  The NICK_CHANGE notify is distributed to
+         the local clients on the channel.  After the changing nickname
+         in router environment snhould work and the [<unknown>] nickname
+         should appear no more.
+         The silc_server_replace_id function that receives the Replace ID
+         payload now sends the NICK_CHANGE notify type also in the file
+         silcd/packet_receive.c
+
+       * Changed WHOIS and IDENTIFY command to support the maximum amount
+         of arguments defined in protocol specs (3328 arguments).  This 
+         fixed a bug that caused problems when there were more than three
+         users on a channel.
+
+Fri Feb  2 11:42:56 EET 2001  Pekka Riikonen <priikone@poseidon.pspt.fi>
+
+       * Added extra parameter, command identifier, to the
+         silc_client_send_command so that explicit command identifier
+         can be defined.
+
+         Changed that ID list routines uses specific command identifier
+         when sending WHOIS/IDENTIFY requests to the server so that they
+         can be identified when the reply comes back.
+
+         Affected files lib/silcclient/command.[ch],
+         lib/silcclient/client.c and lib/silcclient/idlist.[ch].
+
+       * Added `sender' argument to silc_server_packet_send_to_channel
+         to indicaet the sender who originally sent the packet to us
+         that we are now re-sending.  Ignored if NULL.  Affected file
+         silcd/packet_send.[ch].
+
+       * Added some server statistics support in silcd/server_internal.h
+         SilcServerStatistics structure and around the server code.  Also
+         send some nice statistics information when client is connecting
+         to the client.
+
+Thu Feb  1 23:31:21 EET 2001  Pekka Riikonen <priikone@poseidon.pspt.fi>
+
+       * Fixed channel ID decoding in server's JOIN command reply in
+         silcd/command_reply.c
+
+       * Fixed braodcasting of replace ID payload to not to send it if
+         we are standalone server in silcd/packet_receive.c.
+
+       * Fixed all channel message sending routines to not to send
+         packets to clients that has router set, since they are routed
+         separately in the same function earlier.  Affects file
+         silcd/packet_send.c and all channel packet sending functions.
+
+        * In USERS reply, res_argv[i] are not allocated, the table
+          is allocated.  Thus changed that free the table, not its
+          internals.
+
+       * In server's whois_check and identify_check if the client is
+         locally connected do not send any WHOIS commands - they are not
+         needed.
+
+Thu Feb  1 21:32:27 EET 2001  Pekka Riikonen <priikone@poseidon.pspt.fi>
+
+       * Fixed some minor bugs in client when sending WHOIS command.  The
+         arguments was in wrong order.
+
+       * Removed statis function add_to_channel from server in 
+         silcd/command.c that was previously used with the joining but
+         is obsolete now.
+
+       * Tested USERS command in router environment successfully with two
+         routers, two servers and two clients.
+
+Thu Feb  1 00:54:26 EET 2001  Pekka Riikonen <priikone@poseidon.pspt.fi>
+
+       * Reorganized the USERS command and command reply in client library
+         in lib/silcclient/command.c and lib/silcclient/command_reply.c.
+         When the command is given by user we register a pending command
+         callback that will reprocess the command after the reply has been
+         received from the server.  When reprocessing the packet we then
+         display the information.  Thus, the USERS information is displayed
+         now in the command callback instead of in the command reply
+         callback.  The processing of the command is same as previously
+         when server has sent the command reply in the JOINing process.
+
+       * Added to USERS command in silcd/command_reply.c to join the client,
+         we didn't use to know about, to the channel after we've created
+         a client entry for it.  Also, for clienet we did know already still
+         check whether it is on the channel or not and add it if not.
+
+       * Removed silc_server_command_join_notify as the function and its
+         use was obsolete.
+
+Tue Jan 30 22:39:15 EET 2001  Pekka Riikonen <priikone@poseidon.pspt.fi>
+
+       * Changed the client's pending command handling to the same as the
+         server's pending command handling.  It is also now possible to
+         execute command reply functions from other command reply
+         function as the function callbacks for commands and command
+         replies are one and same.  The pending commands are not static
+         list anymore, it is mallocated SilcDList in lib/silcclient/client.h
+         in client connection context.  Thus, pending commands are server
+         connection specific as it is convenient.
+
+         Changed the function silc_client_command_pending and
+         silc_client_command_pending_del and added new function
+         silc_client_command_pending_check.  Removed the 
+         SILC_CLIENT_CMD_REPLY_EXEC, and SILC_CLIENT_PENDING_COMMAND_CHECK
+         macros.
+
+       * Added cmd_ident, current command identifier, to the client
+         connection context in lib/silcclient/client.h to keep track on
+         command identifiers used in command sending.  Client's command reply
+         function handling now supports the mandatory command identifiers.
+
+       * Added SILC_CLIENT_COMMAND_EXEC_PENDING macros to all command reply
+         funtions in client to fully support pending command callbacks.
+
+       * NOTE: the name_list in USERS (old NAMES) command is NOT sent anymore
+         as one of the arguments to the application in the command reply
+         client operation.
+
+       * NOTE: The FORWARDED flag is depracated.  It used to be depracated
+         before first releasing SILC but came back.  Now it is removed again
+         and should come back nomore.  The FORWARDED flag was used only
+         by the JOINing procedure by forwarding the command packet to router.
+         Now, the JOINing procedure has been changed to more generic (due
+         to various router environment issues) and FORWARDED is not needed
+         anymore for anything.  The protocol specification is yet to be
+         updated.
+
+         Now, removed silc_server_packet_forward from server and the flag
+         SILC_PACKET_FORWARDED from lib/silccore/silcpacket.h.
+
+Tue Jan 30 00:05:05 EET 2001  Pekka Riikonen <priikone@poseidon.pspt.fi>
+
+       * Renamed NAMES command to USERS command.  The NAMES was named that
+         due to historical reasons.  Now it is renamed.  Also, rewrote
+         parts of the USERS command.  The nickname list is not sent anymore
+         by the server.  Only Client ID and mode lists are sent in the USERS
+         command.  Changed this also to the protocol specification.
+
+         The client now resolves the names and stuff after it receives
+         the USERS list from the server when joining to the channel.
+
+       * WHOIS and IDENTIFY commands has been changed to support multiple
+         Client ID's per command.  One can now search for multiple users
+         in the network by sending only one WHOIS or IDENTIFY command.
+         Changed the code and the protocol specifications.
+
+       * Removed silc_server_command_identify_parse and changed that IDENTIFY
+         uses silc_server_command_whois_parse to parse the request. */
+
+       * If normal server, do not parse the WHOIS and IDENTIFY requests
+         before sending it to the router.  Saves some time.
+
+Sun Jan 28 16:19:49 EET 2001  Pekka Riikonen <priikone@poseidon.pspt.fi>
+
+       * Fixed JOIN command on client library.  Wrong number of arguments
+         used to crash the client.
+
+       * Added silc_server_channel_has_global function to check whether
+         channel has global users or not.
+
+       * Added silc_server_channel_has_local function to check whether channel
+         has locally connected clients on the channel.
+
+       * The silc_server_remove_from_one_channel now checks whether the
+         channel has global users or not after given client was removed from
+         the channel.  It also checks whether the channel has local clients
+         on the channel anymore.  If it does not have then the channel entry
+         is removed as it is not needed anymore.
+
+       * The silc_server_notify now checks on JOIN notify whether the joining
+         client is one of locally connected or global.  If it is global then
+         the channel has now global users on the channel and that is marked
+         to the channel entry.  Also, it now saves the global client to
+         global list who is joining and JOINs it to the channel.  This is
+         for normal server, that is.
+
+         Changed silc_server_send_notify_on_channel, 
+         silc_server_packet_relay_to_channel and 
+         silc_server_packet_send_to_channel check if we are normal server
+         and client has router set (ie. global client) do not send the
+         message to that client, as it is already routed to our router.
+
+       * Implemented LEAVE notify type handling in silc_server_notify 
+         function.
+
+       * Tested LEAVE command in router environment successfully.  Tested
+         with two routers, two servers and two clients.
+
+       * Updated TODO.
+
+       * idlist_find_xxx_by_id routines now dumps the ID on the debug mode.
+
+       * Implemented SIGNOFF notify type handling in silc_server_notify
+         function.
+
+       * silc_server_remove_id now removes the client entry from all channels
+         it has joined and thusly sends SIGNOFF notify type.
+
+       * Rewrote the NAMES list generation in server by removing two excess
+         loops.  The lists are created now inside one loop.
+
+Sat Jan 27 22:34:56 EET 2001  Pekka Riikonen <priikone@poseidon.pspt.fi>
+
+       * silc_server_remove_channel_user checks now also global list
+         for channel and client.
+
+       * silc_server_new_channel_user checks now both local and global
+         list for channel and client.  Fixed a bug in client id decoding.
+         Used to decode wrong buffer.
+
+       * silc_server_channel_message checks now both local and global
+         list for channel entry.
+
+       * Tested channel joining (hence JOIN) in router environment
+         successfully.  Tested with two routers, two servers and two
+         clients.
+
+       * Tested channel message sending in router environment successfully.
+
+Thu Jan 11 03:22:57 EET 2001  Pekka Riikonen <priikone@poseidon.pspt.fi>
+
+       * Added silc_server_save_channel_key into server.[ch] to save the
+         received channel key in Channel Key payload processing. It is
+         also used in JOIN command reply handling.
+
+         Equivalent function silc_client_save_channel_key added into
+         client.[ch] into client library.
+
+       * Changed JOIN command reply to send information whether the channel
+         was created or not (is existing already) and the channel key 
+         payload.  Changed protocol specs accordingly.
+
+       * Fixed bugs in WHOIS and IDENTIFY command reply sending when
+         the request was sent by ID and not by nickname.  Crashed on
+         NULL dereference.
+
+Sat Dec 23 21:55:07 EET 2000  Pekka Riikonen <priikone@poseidon.pspt.fi>
+
+       * Fixed a bug in Client library.  IDENTIFY and WHOIS reply functions
+         now correctly save the received data.
+
+       * silc_server_free_sock_user_data now notifies routers in the 
+         network about entities leaving the network.
+
+         At the same time implemented functions silc_server_remove_id
+         and silc_server_send_remove_id to receive and send REMOVE_ID
+         packets.  The packet is used to notify routers in the network
+         about leaving entities.  The ID removed will become invalid in
+         the network.
+
+       * Added function silc_idlist_del_server into server. Removes and
+         free's server entry from ID list.
+
+       * silc_server_private_message function now checks, if we are router,
+         that the destination ID really is valid ID, naturally.
+
+       * In router when NEW_ID packet is received (for new client) the
+         hash of the Client ID is saved in the ID Cache but the
+         client->nickname is set to NULL, instead of putting the hash
+         to it as well.
+
+         IDENTIFY command now also checks that client->nickname must be
+         valid. If it is not if will request the data from the server who
+         owns the client.  Added new function 
+         silc_server_command_identify_check.
+
+       * Added silc_command_set_command into lib/silccore/silcommand.[ch]
+         to set the command to already allocated Command Payload.
+
+       * Tested private message sending in router environment with two
+         routers, two servers and two clients.  Fixed minor bugs and now
+         it works fine.
+
+       * Fixed segfault from client's NAMES command. Used to crash if
+         not on any channel.
+
+       * Forwarded packets must not be routed even if it is not destined
+         to the receiver.  Changed server code comply with this.
+
+Sun Dec 17 14:40:08 EET 2000  Pekka Riikonen <priikone@poseidon.pspt.fi>
+
+       * Added `require_reverse_mapping' boolean value to ServerParams
+         structure. If TRUE (not default) the server will require that
+         the connecting host has fully qualified domain name.
+
+         If the reverse mapping is not required and hostname could not be
+         found the IP address is used as hostname.
+
+Sat Dec 16 17:39:54 EET 2000  Pekka Riikonen <priikone@poseidon.pspt.fi>
+
+       * Implemented version string checking to both client and server.
+         The check is incomplete currently due to the abnormal version 
+         strings used in development version of SILC.
+
+       * Changed all command functions in server to use the new
+         CHECK_ARGS macro.
+
+Fri Dec 15 15:55:12 EET 2000  Pekka Riikonen <priikone@poseidon.pspt.fi>
+
+       * Changed char *data to unsigned char *data in ID Cache system to
+         support binary data as ID Cache data. Changed code to support
+         binary data in lib/silccore/idcache.c.
+
+       * Renamed silc_server_packet_relay_command_reply to 
+         silc_server_command_reply as it is normal packet receiving
+         function. Rewrote the function to accept command replys for
+         servers and not only for clients.
+
+       * Mark remote router always as registered server if we are connecting
+         to it.  Otherwise, commands sent by the router to us are ignored.
+
+       * All ID List find routines now returns the ID Cache Entry pointer
+         as well if requested.
+
+       * WHOIS command works now in router environment, tested with two
+         routers, two servers and two clients.
+
+       * Cleaned up and rewrote IDENTIFY command. IDENTIFY should work now
+         in router environment (as it is almost equivalent to WHOIS) but
+         hasn't been tested thoroughly.  Added new functions:
+
+         silc_server_command_identify_parse
+         silc_server_command_identify_send_reply
+         silc_server_command_identify_from_client
+         silc_server_command_identify_from_server
+
+       * Disabled route cache adding because adding two different ID's with
+         same IP replaces the old cache entry thus giving wrong route.
+         The entry->router->connection is always the fastest route anyway
+         so route cache may not be needed.  Of course, new routes maybe
+         established after receiving the ID when the entry->router->connection
+         might not be anymore the most optimal.
+
+Thu Dec 14 15:55:35 EET 2000  Pekka Riikonen <priikone@poseidon.pspt.fi>
+
+       * Add route cache for received ID for fast routing.
+
+       * Added silc_server_packet_route to route received packet on router
+         that is not destined to us.
+
+       * Renamed silc_server_get_route to silc_server_route_get.
+
+       * Added id_string and id_string_len fields into SilcServer to
+         include encoded ServerID for fast comparing without excess
+         encoding of the ID's.
+
+       * Cleaned up WHOIS command on server side. Added following static
+         functions:
+
+         silc_server_command_whois_parse
+         silc_server_command_whois_check
+         silc_server_command_whois_send_reply
+         silc_server_command_whois_from_client
+         silc_server_command_whois_from_server
+
+       * Added macro SILC_SERVER_COMMAND_CHECK_ARGC to check mandatory
+         arguments in command replies. All command functions should be
+         updated to use this macro.
+
+Sun Dec 10 23:52:00 EET 2000  Pekka Riikonen <priikone@poseidon.pspt.fi>
+
+       * Minor typo fixes on command reply handling on server.
+
+Tue Nov 28 11:05:39 EET 2000  Pekka Riikonen <priikone@poseidon.pspt.fi>
+
+       * Added silc_server_command_add_to_channel internal routine to add
+         the client to the channel after router has created the channel and
+         sent command reply to the server.
+
+       * Added generic silc_server_send_command to send any command from
+         server.
+
+       * Use static buffer with ID rendering instead of duplicating data.
+
+Mon Nov 27 21:39:40 EET 2000  Pekka Riikonen <priikone@poseidon.pspt.fi>
+
+       * Fixed a channel user mode bug when joining to a channel server gave
+         everybody channel founder rights, oops.
+
+       * We mark ourselves as the router of the incoming server connection
+         if we are router ourselves.  This way we can check in some packet
+         sending functions whether it is locally connected server.  For
+         incoming router connections we put NULL.
+
+       * For router sending packets locally means now always sending the
+         packet cell wide; to local clients and local servers.  For normal
+         server sending packet locally means sending it to only local
+         clients.
+
+       * Fixed the JOIN command to really work in router environment.  If the
+         channel is created it is always created by the router.  Router is
+         also responsible of making the initial joining to the channel,
+         sending JOIN notify to the sending server and distributing 
+         NEW_CHANNEL and NEW_CHANNEL_USER packets.  Hence, if the channel
+         does not exist server doesn't do anything else but forward the
+         command to the router which performs everything.
+
+       * Added silc_server_send_channel_key function to send the Channel Key
+         payload.
+
+       * Added silc_server_create_channel_key to create new channel key.  The
+         channel key is now re-generated everytime someone joins or leaves
+         a channel, as protocol dictates.  Note: channel->key_len is the
+         key length in bits.
+
+Wed Nov 22 22:14:19 EET 2000  Pekka Riikonen <priikone@poseidon.pspt.fi>
+
+       * Splitted server.[ch] finally.  Created now packet_send.[ch] and
+         packet_receive.[ch] to separate packet sending and receiving
+         routines.  The server.[ch] now includes everything else including
+         actual packet processing (writing and reading data) and other
+         server issues.
+
+         Renamed silc_server_private_message_send_internal to
+         silc_server_send_private_message.  The routine is still though
+         used only to relay private messages as server does not send
+         private messages itself.
+
+         Renamed silc_server_new_channel to silc_server_create_new_channel
+         and added new function sicl_server_new_channel that handles the
+         incoming New Channel packet.  Added also new sending function
+         silc_server_send_new_channel to send New Channel Payload.
+
+       * Added new function silc_server_notify to process incoming notify
+         packet to the server/router. Server may then relay the notify
+         to clients if needed.
+
+       * Added new function silc_server_new_channel_user to process incoming
+         New Channel User packet.  Router will redistribute the packet and
+         send JOIN notify to its local clients and locally connected servers
+         if needed.  Normal server will send JOIN notify to its local client
+         on same channel when received this packet.  Added also corresponding
+         sending function silc_server_send_new_channel_user to sent the
+         payload.
+
+       * Added boolean route argument to send_notif_to_channel and
+         packet_send_to_channel functions to attempt to route the packet
+         if it is TRUE and send only locally if it is FALSE.
+
 Tue Nov 21 19:49:31 EET 2000  Pekka Riikonen <priikone@poseidon.pspt.fi>
 
        * silc_server_replace_id now broadcasts the received replace ID