Use string into Descriptor Data Sub Message Element

This commit is contained in:
vemax78 2013-08-19 22:28:41 +02:00
parent d3f1f50c1f
commit e53808c0d6
3 changed files with 13 additions and 9 deletions

View File

@ -61,15 +61,18 @@ static void capwap_wtpdescriptor_element_create(void* data, capwap_message_eleme
/* */
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);
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_u16(handle, desc->type);
func->write_u16(handle, desc->length);
func->write_block(handle, desc->data, desc->length);
func->write_u16(handle, 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 */
while (func->read_ready(handle) > 0) {
unsigned short length;
uint16_t lengthdesc;
struct capwap_wtpdescriptor_desc_subelement* desc;
/* 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);
func->read_u32(handle, &desc->vendor);
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)) {
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 */
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_wtpdescriptor_element_free(data);
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;

View File

@ -29,7 +29,6 @@ struct capwap_wtpdescriptor_encrypt_subelement {
struct capwap_wtpdescriptor_desc_subelement {
uint32_t vendor;
uint16_t type;
uint16_t length;
uint8_t* data;
};

View File

@ -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->vendor = (unsigned long)configVendor;
desc->type = type;
desc->length = lengthValue;
desc->data = (uint8_t*)capwap_clone((void*)configValue, lengthValue);
desc->data = (uint8_t*)capwap_duplicate_string(configValue);
} else {
capwap_logging_error("Invalid configuration file, application.descriptor.info.value string length exceeded");
return 0;