restrict PA-TNC messages to maximum size
This commit is contained in:
@@ -355,12 +355,31 @@ static char* get_str_attribute(private_imv_agent_t *this, TNC_ConnectionID id,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read an UInt32 attribute
|
||||
*/
|
||||
static u_int32_t get_uint_attribute(private_imv_agent_t *this, TNC_ConnectionID id,
|
||||
TNC_AttributeID attribute_id)
|
||||
{
|
||||
TNC_UInt32 len;
|
||||
char buf[4];
|
||||
|
||||
if (this->get_attribute &&
|
||||
this->get_attribute(this->id, id, attribute_id, 4, buf, &len) ==
|
||||
TNC_RESULT_SUCCESS && len == 4)
|
||||
{
|
||||
return untoh32(buf);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
METHOD(imv_agent_t, create_state, TNC_Result,
|
||||
private_imv_agent_t *this, imv_state_t *state)
|
||||
{
|
||||
TNC_ConnectionID conn_id;
|
||||
char *tnccs_p = NULL, *tnccs_v = NULL, *t_p = NULL, *t_v = NULL;
|
||||
bool has_long = FALSE, has_excl = FALSE, has_soh = FALSE;
|
||||
u_int32_t max_msg_len;
|
||||
|
||||
conn_id = state->get_connection_id(state);
|
||||
if (find_connection(this, conn_id))
|
||||
@@ -379,14 +398,18 @@ METHOD(imv_agent_t, create_state, TNC_Result,
|
||||
tnccs_v = get_str_attribute(this, conn_id, TNC_ATTRIBUTEID_IFTNCCS_VERSION);
|
||||
t_p = get_str_attribute(this, conn_id, TNC_ATTRIBUTEID_IFT_PROTOCOL);
|
||||
t_v = get_str_attribute(this, conn_id, TNC_ATTRIBUTEID_IFT_VERSION);
|
||||
max_msg_len = get_uint_attribute(this, conn_id, TNC_ATTRIBUTEID_MAX_MESSAGE_SIZE);
|
||||
|
||||
state->set_flags(state, has_long, has_excl);
|
||||
state->set_max_msg_len(state, max_msg_len);
|
||||
|
||||
DBG2(DBG_IMV, "IMV %u \"%s\" created a state for %s %s Connection ID %u: "
|
||||
"%slong %sexcl %ssoh", this->id, this->name,
|
||||
tnccs_p ? tnccs_p:"?", tnccs_v ? tnccs_v:"?", conn_id,
|
||||
has_long ? "+":"-", has_excl ? "+":"-", has_soh ? "+":"-");
|
||||
DBG2(DBG_IMV, " over %s %s with maximum PA-TNC msg size of %u bytes",
|
||||
t_p ? t_p:"?", t_v ? t_v :"?", max_msg_len);
|
||||
|
||||
DBG2(DBG_IMV, "IMV %u \"%s\" created a state for Connection ID %u: "
|
||||
"%s %s with %slong %sexcl %ssoh over %s %s",
|
||||
this->id, this->name, conn_id, tnccs_p ? tnccs_p:"?",
|
||||
tnccs_v ? tnccs_v:"?", has_long ? "+":"-", has_excl ? "+":"-",
|
||||
has_soh ? "+":"-", t_p ? t_p:"?", t_v ? t_v :"?");
|
||||
free(tnccs_p);
|
||||
free(tnccs_v);
|
||||
free(t_p);
|
||||
|
||||
Reference in New Issue
Block a user