protection against insane IMCs and IMVs
This commit is contained in:
@@ -28,6 +28,12 @@ TNC_Result TNC_TNCC_ReportMessageTypes(TNC_IMCID imc_id,
|
||||
TNC_MessageTypeList supported_types,
|
||||
TNC_UInt32 type_count)
|
||||
{
|
||||
if (!charon->imcs->is_registered(charon->imcs, imc_id))
|
||||
{
|
||||
DBG1(DBG_TNC, "ignoring ReportMessageTypes() from unregistered IMC %u",
|
||||
imc_id);
|
||||
return TNC_RESULT_INVALID_PARAMETER;
|
||||
}
|
||||
return charon->imcs->set_message_types(charon->imcs, imc_id,
|
||||
supported_types, type_count);
|
||||
}
|
||||
@@ -39,6 +45,12 @@ TNC_Result TNC_TNCC_RequestHandshakeRetry(TNC_IMCID imc_id,
|
||||
TNC_ConnectionID connection_id,
|
||||
TNC_RetryReason reason)
|
||||
{
|
||||
if (!charon->imcs->is_registered(charon->imcs, imc_id))
|
||||
{
|
||||
DBG1(DBG_TNC, "ignoring RequestHandshakeRetry() from unregistered IMC %u",
|
||||
imc_id);
|
||||
return TNC_RESULT_INVALID_PARAMETER;
|
||||
}
|
||||
return charon->tnccs->request_handshake_retry(charon->tnccs, TRUE, imc_id,
|
||||
connection_id, reason);
|
||||
}
|
||||
@@ -52,6 +64,12 @@ TNC_Result TNC_TNCC_SendMessage(TNC_IMCID imc_id,
|
||||
TNC_UInt32 msg_len,
|
||||
TNC_MessageType msg_type)
|
||||
{
|
||||
if (!charon->imcs->is_registered(charon->imcs, imc_id))
|
||||
{
|
||||
DBG1(DBG_TNC, "ignoring SendMessage() from unregistered IMC %u",
|
||||
imc_id);
|
||||
return TNC_RESULT_INVALID_PARAMETER;
|
||||
}
|
||||
return charon->tnccs->send_message(charon->tnccs, imc_id, TNC_IMVID_ANY,
|
||||
connection_id, msg, msg_len, msg_type);
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ METHOD(imc_manager_t, remove_, imc_t*,
|
||||
private_tnc_imc_manager_t *this, TNC_IMCID id)
|
||||
{
|
||||
enumerator_t *enumerator;
|
||||
imc_t *imc;
|
||||
imc_t *imc, *removed_imc = NULL;
|
||||
|
||||
enumerator = this->imcs->create_enumerator(this->imcs);
|
||||
while (enumerator->enumerate(enumerator, &imc))
|
||||
@@ -85,11 +85,34 @@ METHOD(imc_manager_t, remove_, imc_t*,
|
||||
if (id == imc->get_id(imc))
|
||||
{
|
||||
this->imcs->remove_at(this->imcs, enumerator);
|
||||
return imc;
|
||||
removed_imc = imc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
return NULL;
|
||||
|
||||
return removed_imc;
|
||||
}
|
||||
|
||||
METHOD(imc_manager_t, is_registered, bool,
|
||||
private_tnc_imc_manager_t *this, TNC_IMCID id)
|
||||
{
|
||||
enumerator_t *enumerator;
|
||||
imc_t *imc;
|
||||
bool found = FALSE;
|
||||
|
||||
enumerator = this->imcs->create_enumerator(this->imcs);
|
||||
while (enumerator->enumerate(enumerator, &imc))
|
||||
{
|
||||
if (id == imc->get_id(imc))
|
||||
{
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
METHOD(imc_manager_t, get_preferred_language, char*,
|
||||
@@ -228,6 +251,7 @@ imc_manager_t* tnc_imc_manager_create(void)
|
||||
.public = {
|
||||
.add = _add,
|
||||
.remove = _remove_, /* avoid name conflict with stdio.h */
|
||||
.is_registered = _is_registered,
|
||||
.get_preferred_language = _get_preferred_language,
|
||||
.notify_connection_change = _notify_connection_change,
|
||||
.begin_handshake = _begin_handshake,
|
||||
|
||||
Reference in New Issue
Block a user