WATCH notify sending.
crashes on AMD64. Affected files are lib/silcutil/silcbuffmt.h,
lib/silcclient/silcvcard.c, silcd/server_util.c.
+ * Fixed the adding of public key to the WATCH list in server.
+ Fixed the WATCH notify sending to client. Affected files
+ are silcd/packet_send.[ch], command.c, server_util.c.
+
+ * Implemented the watching by public key in the SILC Client
+ Library and SILC Client. Affected files are
+ lib/silcclient/command.c and client_notify.c.
+
Mon Feb 23 09:30:30 CET 2004 Pekka Riikonen <priikone@silcnet.org>
* Added support for public key watching in server. Affected
}
/* Take public key for watching by public key */
- pk = silc_argument_get_arg_type(cmd->args, 3, &pk_len);
+ pk = silc_argument_get_arg_type(cmd->args, 4, &pk_len);
/* Take nickname */
add_nick = silc_argument_get_arg_type(cmd->args, 2, &add_nick_len);
0);
goto out;
}
-
+
pk = silc_argument_get_next_arg(pkargs, &type, &pk_len);
while (pk) {
if (!silc_pkcs_public_key_payload_decode(pk, pk_len, &public_key))
/* Add the client to the watcher list with the specified public
key. */
- silc_hash_table_add(server->watcher_list, public_key, client);
+ silc_hash_table_add(server->watcher_list_pk, pkkey, client);
} else if (type == 0x01) {
/* Delete public key from watch list */
silc_hash_table_del_by_context(server->watcher_list_pk,
public_key, client);
- /* Now check whether there still exists entries with this key, if
+ /* Now check whether there still exists entries with this key, if
not then free the key to not leak memory. */
- if (!silc_hash_table_find(server->watcher_list, hash, NULL, NULL))
+ if (!silc_hash_table_find(server->watcher_list_pk, hash, NULL, NULL))
silc_pkcs_public_key_free(pkkey);
silc_pkcs_public_key_free(public_key);
}
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 1997 - 2003 Pekka Riikonen
+ Copyright (C) 1997 - 2004 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
}
memcpy(iv, data + (data_len - iv_len - mac_len), iv_len);
- silc_message_payload_encrypt(data, totlen, data_len - mac_len,
- iv, iv_len, channel->channel_key,
+ silc_message_payload_encrypt(data, totlen, data_len - mac_len,
+ iv, iv_len, channel->channel_key,
channel->hmac);
}
SilcClientEntry watcher,
SilcClientEntry client,
const char *nickname,
- SilcNotifyType type)
+ SilcNotifyType type,
+ SilcPublicKey public_key)
{
- SilcBuffer idp;
+ SilcBuffer idp, pkp = NULL;
unsigned char mode[4], n[2];
idp = silc_id_payload_encode(client->id, SILC_ID_CLIENT);
SILC_PUT16_MSB(type, n);
SILC_PUT32_MSB(client->mode, mode);
+ if (public_key)
+ pkp = silc_pkcs_public_key_payload_encode(public_key);
silc_server_send_notify_dest(server, sock, FALSE, watcher->id,
SILC_ID_CLIENT, SILC_NOTIFY_TYPE_WATCH,
- 4, idp->data, idp->len,
+ 5, idp->data, idp->len,
nickname, nickname ? strlen(nickname) : 0,
mode, sizeof(mode),
type != SILC_NOTIFY_TYPE_NONE ?
- n : NULL, sizeof(n));
+ n : NULL, sizeof(n),
+ pkp ? pkp->data : NULL,
+ pkp ? pkp->len : 0);
silc_buffer_free(idp);
+ silc_buffer_free(pkp);
}
/* Sends notify message destined to specific entity. */
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 1997 - 2003 Pekka Riikonen
+ Copyright (C) 1997 - 2004 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
+ the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
SilcClientEntry watcher,
SilcClientEntry client,
const char *nickname,
- SilcNotifyType type);
+ SilcNotifyType type,
+ SilcPublicKey public_key);
void silc_server_send_notify_dest(SilcServer server,
SilcSocketConnection sock,
bool broadcast,
SilcNotifyType type,
SilcUInt32 argc, ...);
-#endif
+#endif /* PACKET_SEND_H */
notify->client,
notify->new_nick ? notify->new_nick :
(const char *)notify->client->nickname,
- notify->notify);
+ notify->notify,
+ notify->client->data.public_key);
}
}
}
silc_hash_table_list_reset(&htl);
+ silc_hash_table_list(server->watcher_list_pk, &htl);
+ while (silc_hash_table_get(&htl, &key, (void *)&entry)) {
+ if (entry == client) {
+ silc_hash_table_del_by_context(server->watcher_list_pk, key, client);
+
+ if (client->id)
+ SILC_LOG_DEBUG(("Removing %s from WATCH list",
+ silc_id_render(client->id, SILC_ID_CLIENT)));
+
+ /* Now check whether there still exists entries with this key, if not
+ then free the key to not leak memory. */
+ if (!silc_hash_table_find(server->watcher_list_pk, key, NULL, NULL))
+ silc_pkcs_public_key_free(key);
+
+ found = TRUE;
+ }
+ }
+ silc_hash_table_list_reset(&htl);
+
return found;
}