Use string into Descriptor Data Sub Message Element
This commit is contained in:
parent
d3f1f50c1f
commit
e53808c0d6
@ -61,15 +61,18 @@ static void capwap_wtpdescriptor_element_create(void* data, capwap_message_eleme
|
|||||||
|
|
||||||
/* */
|
/* */
|
||||||
for (i = 0; i < element->descsubelement->count; i++) {
|
for (i = 0; i < element->descsubelement->count; i++) {
|
||||||
|
uint16_t length;
|
||||||
struct capwap_wtpdescriptor_desc_subelement* desc = (struct capwap_wtpdescriptor_desc_subelement*)capwap_array_get_item_pointer(element->descsubelement, i);
|
struct capwap_wtpdescriptor_desc_subelement* desc = (struct capwap_wtpdescriptor_desc_subelement*)capwap_array_get_item_pointer(element->descsubelement, i);
|
||||||
|
|
||||||
ASSERT((desc->type >= CAPWAP_WTPDESC_SUBELEMENT_TYPE_FIRST) && (desc->type <= CAPWAP_WTPDESC_SUBELEMENT_TYPE_LAST));
|
ASSERT((desc->type >= CAPWAP_WTPDESC_SUBELEMENT_TYPE_FIRST) && (desc->type <= CAPWAP_WTPDESC_SUBELEMENT_TYPE_LAST));
|
||||||
ASSERT(desc->length > 0);
|
|
||||||
|
length = strlen((char*)desc->data);
|
||||||
|
ASSERT(length > 0);
|
||||||
|
|
||||||
func->write_u32(handle, desc->vendor);
|
func->write_u32(handle, desc->vendor);
|
||||||
func->write_u16(handle, desc->type);
|
func->write_u16(handle, desc->type);
|
||||||
func->write_u16(handle, desc->length);
|
func->write_u16(handle, length);
|
||||||
func->write_block(handle, desc->data, desc->length);
|
func->write_block(handle, desc->data, length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,6 +160,7 @@ static void* capwap_wtpdescriptor_element_parsing(capwap_message_elements_handle
|
|||||||
/* WTP Description Subelement */
|
/* WTP Description Subelement */
|
||||||
while (func->read_ready(handle) > 0) {
|
while (func->read_ready(handle) > 0) {
|
||||||
unsigned short length;
|
unsigned short length;
|
||||||
|
uint16_t lengthdesc;
|
||||||
struct capwap_wtpdescriptor_desc_subelement* desc;
|
struct capwap_wtpdescriptor_desc_subelement* desc;
|
||||||
|
|
||||||
/* Check */
|
/* Check */
|
||||||
@ -170,7 +174,7 @@ static void* capwap_wtpdescriptor_element_parsing(capwap_message_elements_handle
|
|||||||
desc = (struct capwap_wtpdescriptor_desc_subelement*)capwap_array_get_item_pointer(data->descsubelement, data->descsubelement->count);
|
desc = (struct capwap_wtpdescriptor_desc_subelement*)capwap_array_get_item_pointer(data->descsubelement, data->descsubelement->count);
|
||||||
func->read_u32(handle, &desc->vendor);
|
func->read_u32(handle, &desc->vendor);
|
||||||
func->read_u16(handle, &desc->type);
|
func->read_u16(handle, &desc->type);
|
||||||
func->read_u16(handle, &desc->length);
|
func->read_u16(handle, &lengthdesc);
|
||||||
|
|
||||||
if ((desc->type < CAPWAP_WTPDESC_SUBELEMENT_TYPE_FIRST) || (desc->type > CAPWAP_WTPDESC_SUBELEMENT_TYPE_LAST)) {
|
if ((desc->type < CAPWAP_WTPDESC_SUBELEMENT_TYPE_FIRST) || (desc->type > CAPWAP_WTPDESC_SUBELEMENT_TYPE_LAST)) {
|
||||||
capwap_logging_debug("Invalid WTP Descriptor subelement: invalid type");
|
capwap_logging_debug("Invalid WTP Descriptor subelement: invalid type");
|
||||||
@ -180,13 +184,15 @@ static void* capwap_wtpdescriptor_element_parsing(capwap_message_elements_handle
|
|||||||
|
|
||||||
/* Check buffer size */
|
/* Check buffer size */
|
||||||
length = func->read_ready(handle);
|
length = func->read_ready(handle);
|
||||||
if (!length || (length > CAPWAP_WTPDESC_SUBELEMENT_MAXDATA) || (length < desc->length)) {
|
if (!length || (length > CAPWAP_WTPDESC_SUBELEMENT_MAXDATA) || (length < lengthdesc)) {
|
||||||
capwap_logging_debug("Invalid WTP Descriptor element");
|
capwap_logging_debug("Invalid WTP Descriptor element");
|
||||||
capwap_wtpdescriptor_element_free(data);
|
capwap_wtpdescriptor_element_free(data);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
func->read_block(handle, desc->data, desc->length);
|
desc->data = (uint8_t*)capwap_alloc(lengthdesc + 1);
|
||||||
|
func->read_block(handle, desc->data, lengthdesc);
|
||||||
|
desc->data[lengthdesc] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
@ -29,7 +29,6 @@ struct capwap_wtpdescriptor_encrypt_subelement {
|
|||||||
struct capwap_wtpdescriptor_desc_subelement {
|
struct capwap_wtpdescriptor_desc_subelement {
|
||||||
uint32_t vendor;
|
uint32_t vendor;
|
||||||
uint16_t type;
|
uint16_t type;
|
||||||
uint16_t length;
|
|
||||||
uint8_t* data;
|
uint8_t* data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -554,8 +554,7 @@ static int wtp_parsing_configuration_1_0(config_t* config) {
|
|||||||
desc = (struct capwap_wtpdescriptor_desc_subelement*)capwap_array_get_item_pointer(g_wtp.descriptor.descsubelement, g_wtp.descriptor.descsubelement->count);
|
desc = (struct capwap_wtpdescriptor_desc_subelement*)capwap_array_get_item_pointer(g_wtp.descriptor.descsubelement, g_wtp.descriptor.descsubelement->count);
|
||||||
desc->vendor = (unsigned long)configVendor;
|
desc->vendor = (unsigned long)configVendor;
|
||||||
desc->type = type;
|
desc->type = type;
|
||||||
desc->length = lengthValue;
|
desc->data = (uint8_t*)capwap_duplicate_string(configValue);
|
||||||
desc->data = (uint8_t*)capwap_clone((void*)configValue, lengthValue);
|
|
||||||
} else {
|
} else {
|
||||||
capwap_logging_error("Invalid configuration file, application.descriptor.info.value string length exceeded");
|
capwap_logging_error("Invalid configuration file, application.descriptor.info.value string length exceeded");
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user