SILC_LOG_DEBUG(("Start"));
- if (protocol->state == SILC_PROTOCOL_STATE_ERROR) {
+ if (protocol->state == SILC_PROTOCOL_STATE_ERROR ||
+ protocol->state == SILC_PROTOCOL_STATE_FAILURE) {
/* Error occured during protocol */
SILC_LOG_DEBUG(("Error during KE protocol"));
silc_protocol_free(protocol);
SILC_LOG_DEBUG(("Start"));
- if (protocol->state == SILC_PROTOCOL_STATE_ERROR) {
+ if (protocol->state == SILC_PROTOCOL_STATE_ERROR ||
+ protocol->state == SILC_PROTOCOL_STATE_FAILURE) {
/* Error occured during protocol */
SILC_LOG_DEBUG(("Error during authentication protocol"));
silc_protocol_free(protocol);
silc_free(ctx->auth_data);
if (ctx->ske)
silc_ske_free(ctx->ske);
- if (ctx->dest_id)
- silc_free(ctx->dest_id);
silc_free(ctx);
conn->sock->protocol = NULL;
}
proto_ctx->packet = silc_packet_context_dup(packet);
proto_ctx->dest_id_type = packet->src_id_type;
- proto_ctx->dest_id = silc_id_str2id(packet->src_id, packet->src_id_type);
+ proto_ctx->dest_id = silc_id_str2id(packet->src_id, packet->src_id_len,
+ packet->src_id_type);
+ if (!proto_ctx->dest_id)
+ break;
/* Let the protocol handle the packet */
sock->protocol->execute(client->timeout_queue, 0,
proto_ctx->packet = silc_packet_context_dup(packet);
proto_ctx->dest_id_type = packet->src_id_type;
- proto_ctx->dest_id = silc_id_str2id(packet->src_id, packet->src_id_type);
+ proto_ctx->dest_id = silc_id_str2id(packet->src_id, packet->src_id_len,
+ packet->src_id_type);
+ if (!proto_ctx->dest_id)
+ break;
/* Let the protocol handle the packet */
sock->protocol->execute(client->timeout_queue, 0,
SilcIDPayload idp;
idp = silc_id_payload_parse(buffer);
+ if (!idp)
+ break;
if (silc_id_payload_get_type(idp) != SILC_ID_CLIENT)
break;
unsigned int tmp_len, mode;
payload = silc_notify_payload_parse(buffer);
+ if (!payload)
+ goto out;
+
type = silc_notify_get_type(payload);
args = silc_notify_get_args(payload);
if (!args)
goto out;
client_id = silc_id_payload_parse_id(tmp, tmp_len);
+ if (!client_id)
+ goto out;
/* Find Client entry and if not found query it */
client_entry = silc_idlist_get_client_by_id(client, conn, client_id, TRUE);
goto out;
channel_id = silc_id_payload_parse_id(tmp, tmp_len);
+ if (!channel_id)
+ goto out;
/* XXX Will ALWAYS fail because currently we don't have way to resolve
channel information for channel that we're not joined to. */
goto out;
client_id = silc_id_payload_parse_id(tmp, tmp_len);
+ if (!client_id)
+ goto out;
/* Find Client entry and if not found query it */
client_entry = silc_idlist_get_client_by_id(client, conn, client_id, TRUE);
}
/* Get channel entry */
- channel_id = silc_id_str2id(packet->dst_id, SILC_ID_CHANNEL);
+ channel_id = silc_id_str2id(packet->dst_id, packet->dst_id_len,
+ SILC_ID_CHANNEL);
+ if (!channel_id)
+ goto out;
if (!silc_idcache_find_by_id_one(conn->channel_cache, (void *)channel_id,
SILC_ID_CHANNEL, &id_cache))
break;
goto out;
client_id = silc_id_payload_parse_id(tmp, tmp_len);
+ if (!client_id)
+ goto out;
/* Find Client entry */
client_entry =
goto out;
/* Get channel entry */
- channel_id = silc_id_str2id(packet->dst_id, SILC_ID_CHANNEL);
+ channel_id = silc_id_str2id(packet->dst_id, packet->dst_id_len,
+ SILC_ID_CHANNEL);
+ if (!channel_id)
+ goto out;
if (!silc_idcache_find_by_id_one(conn->channel_cache, (void *)channel_id,
SILC_ID_CHANNEL, &id_cache))
break;
goto out;
client_id = silc_id_payload_parse_id(tmp, tmp_len);
+ if (!client_id)
+ goto out;
/* Find Client entry */
client_entry =
goto out;
client_id = silc_id_payload_parse_id(tmp, tmp_len);
+ if (!client_id)
+ goto out;
/* Find Client entry */
client_entry =
goto out;
/* Get channel entry */
- channel_id = silc_id_str2id(packet->dst_id, SILC_ID_CHANNEL);
+ channel_id = silc_id_str2id(packet->dst_id, packet->dst_id_len,
+ SILC_ID_CHANNEL);
+ if (!channel_id)
+ goto out;
if (!silc_idcache_find_by_id_one(conn->channel_cache, (void *)channel_id,
SILC_ID_CHANNEL, &id_cache))
break;
goto out;
client_id = silc_id_payload_parse_id(tmp, tmp_len);
+ if (!client_id)
+ goto out;
/* Ignore my ID */
if (!SILC_ID_CLIENT_COMPARE(client_id, conn->local_id))
goto out;
client_id = silc_id_payload_parse_id(tmp, tmp_len);
+ if (!client_id)
+ goto out;
/* Find old Client entry */
client_entry =
goto out;
client_id = silc_id_payload_parse_id(tmp, tmp_len);
+ if (!client_id)
+ goto out;
/* Find Client entry */
client_entry =
SILC_GET32_MSB(mode, tmp);
/* Get channel entry */
- channel_id = silc_id_str2id(packet->dst_id, SILC_ID_CHANNEL);
+ channel_id = silc_id_str2id(packet->dst_id, packet->dst_id_len,
+ SILC_ID_CHANNEL);
+ if (!channel_id)
+ goto out;
if (!silc_idcache_find_by_id_one(conn->channel_cache, (void *)channel_id,
SILC_ID_CHANNEL, &id_cache))
break;
goto out;
client_id = silc_id_payload_parse_id(tmp, tmp_len);
+ if (!client_id)
+ goto out;
/* Find Client entry */
client_entry =
silc_free(client_id);
client_id = silc_id_payload_parse_id(tmp, tmp_len);
+ if (!client_id)
+ goto out;
/* Find target Client entry */
client_entry2 =
goto out;
/* Get channel entry */
- channel_id = silc_id_str2id(packet->dst_id, SILC_ID_CHANNEL);
+ channel_id = silc_id_str2id(packet->dst_id, packet->dst_id_len,
+ SILC_ID_CHANNEL);
+ if (!channel_id)
+ goto out;
if (!silc_idcache_find_by_id_one(conn->channel_cache, (void *)channel_id,
SILC_ID_CHANNEL, &id_cache))
break;
return;
}
- id = silc_id_str2id(id_string, SILC_ID_CHANNEL);
+ id = silc_id_str2id(id_string, tmp_len, SILC_ID_CHANNEL);
+ if (!id) {
+ silc_channel_key_payload_free(payload);
+ return;
+ }
/* Find channel. */
if (!channel) {
if (packet->dst_id_type != SILC_ID_CHANNEL)
goto out;
- client_id = silc_id_str2id(packet->src_id, SILC_ID_CLIENT);
- id = silc_id_str2id(packet->dst_id, SILC_ID_CHANNEL);
+ client_id = silc_id_str2id(packet->src_id, packet->src_id_len,
+ SILC_ID_CLIENT);
+ if (!client_id)
+ goto out;
+ id = silc_id_str2id(packet->dst_id, packet->dst_id_len, SILC_ID_CHANNEL);
+ if (!id)
+ goto out;
/* Find the channel entry from channels on this connection */
if (!silc_idcache_find_by_id_one(conn->channel_cache, (void *)id,
SilcBuffer buffer = packet->buffer;
unsigned short nick_len;
unsigned char *nickname, *message;
+ int ret;
/* Get nickname */
- silc_buffer_unformat(buffer,
- SILC_STR_UI16_NSTRING_ALLOC(&nickname, &nick_len),
- SILC_STR_END);
+ ret = silc_buffer_unformat(buffer,
+ SILC_STR_UI16_NSTRING_ALLOC(&nickname, &nick_len),
+ SILC_STR_END);
+ if (ret == -1)
+ return;
+
silc_buffer_pull(buffer, 2 + nick_len);
-
+
message = silc_calloc(buffer->len + 1, sizeof(char));
memcpy(message, buffer->data, buffer->len);
if (packet->src_id_type != SILC_ID_CLIENT)
goto out;
- remote_id = silc_id_str2id(packet->src_id, SILC_ID_CLIENT);
+ remote_id = silc_id_str2id(packet->src_id, packet->src_id_len,
+ SILC_ID_CLIENT);
if (!remote_id)
goto out;