X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=blobdiff_plain;f=lib%2Fsilcclient%2Fprotocol.c;h=9d9918a0812e50a25a4c89dabb9d0bf79d4cd2dc;hp=b3cbe4a53c1b5696cae76c0a938382f27d633970;hb=0f0340b9fbce9704cc7171f8f0104ce9103d2de6;hpb=d60003d3019371d4ce834a6cbfbf41c257f5a5f7 diff --git a/lib/silcclient/protocol.c b/lib/silcclient/protocol.c index b3cbe4a5..9d9918a0 100644 --- a/lib/silcclient/protocol.c +++ b/lib/silcclient/protocol.c @@ -284,6 +284,14 @@ SILC_TASK_CALLBACK(silc_client_protocol_key_exchange) context); if (ctx->responder == TRUE) { + if (!ctx->packet) { + SILC_LOG_WARNING(("Error (type %d) during Key Exchange protocol", + status)); + protocol->state = SILC_PROTOCOL_STATE_ERROR; + silc_protocol_execute(protocol, client->schedule, 0, 0); + return; + } + /* Start the key exchange by processing the received security properties packet from initiator. */ status = @@ -335,6 +343,14 @@ SILC_TASK_CALLBACK(silc_client_protocol_key_exchange) /* Sends the selected security properties to the initiator. */ status = silc_ske_responder_phase_1(ctx->ske); } else { + if (!ctx->packet) { + SILC_LOG_WARNING(("Error (type %d) during Key Exchange protocol", + status)); + protocol->state = SILC_PROTOCOL_STATE_ERROR; + silc_protocol_execute(protocol, client->schedule, 0, 0); + return; + } + /* Call Phase-1 function. This processes the Key Exchange Start paylaod reply we just got from the responder. The callback function will receive the processed payload where we will @@ -365,6 +381,14 @@ SILC_TASK_CALLBACK(silc_client_protocol_key_exchange) * Phase 2 */ if (ctx->responder == TRUE) { + if (!ctx->packet) { + SILC_LOG_WARNING(("Error (type %d) during Key Exchange protocol", + status)); + protocol->state = SILC_PROTOCOL_STATE_ERROR; + silc_protocol_execute(protocol, client->schedule, 0, 0); + return; + } + /* Process the received Key Exchange 1 Payload packet from the initiator. This also creates our parts of the Diffie Hellman algorithm. The silc_client_protocol_ke_continue will @@ -413,6 +437,14 @@ SILC_TASK_CALLBACK(silc_client_protocol_key_exchange) /* End the protocol on the next round */ protocol->state = SILC_PROTOCOL_STATE_END; } else { + if (!ctx->packet) { + SILC_LOG_WARNING(("Error (type %d) during Key Exchange protocol", + status)); + protocol->state = SILC_PROTOCOL_STATE_ERROR; + silc_protocol_execute(protocol, client->schedule, 0, 0); + return; + } + /* Finish the protocol. This verifies the Key Exchange 2 payload sent by responder. The silc_client_protocol_ke_continue will be called after the public key has been verified. */ @@ -899,6 +931,13 @@ SILC_TASK_CALLBACK(silc_client_protocol_rekey) * using the SKE protocol. */ + if (!ctx->packet) { + SILC_LOG_WARNING(("Error during Re-key")); + protocol->state = SILC_PROTOCOL_STATE_ERROR; + silc_protocol_execute(protocol, client->schedule, 0, 300000); + return; + } + if (ctx->packet->type != SILC_PACKET_KEY_EXCHANGE_1) { /* Error in protocol */ protocol->state = SILC_PROTOCOL_STATE_ERROR; @@ -1038,6 +1077,13 @@ SILC_TASK_CALLBACK(silc_client_protocol_rekey) /* * The packet type must be KE packet */ + if (!ctx->packet) { + SILC_LOG_WARNING(("Error during Re-key")); + protocol->state = SILC_PROTOCOL_STATE_ERROR; + silc_protocol_execute(protocol, client->schedule, 0, 300000); + return; + } + if (ctx->packet->type != SILC_PACKET_KEY_EXCHANGE_2) { /* Error in protocol */ protocol->state = SILC_PROTOCOL_STATE_ERROR; @@ -1077,6 +1123,13 @@ SILC_TASK_CALLBACK(silc_client_protocol_rekey) * End protocol */ + if (!ctx->packet) { + SILC_LOG_WARNING(("Error during Re-key")); + protocol->state = SILC_PROTOCOL_STATE_ERROR; + silc_protocol_execute(protocol, client->schedule, 0, 300000); + return; + } + if (ctx->packet->type != SILC_PACKET_REKEY_DONE) { /* Error in protocol */ protocol->state = SILC_PROTOCOL_STATE_ERROR;