avrcp: fix parsing header of AVRCP_BROWSING_DATA_PACKET

This commit is contained in:
Milanka Ringwald 2018-03-26 23:28:44 +02:00
parent 14e95846d8
commit 9bb24eb5f0

View File

@ -444,13 +444,11 @@ static void avrcp_parser_reset(avrcp_browsing_connection_t * connection){
static void avrcp_browsing_parser_process_byte(uint8_t byte, avrcp_browsing_connection_t * connection){ static void avrcp_browsing_parser_process_byte(uint8_t byte, avrcp_browsing_connection_t * connection){
uint8_t prepended_header_size = 1; uint8_t prepended_header_size = 1;
switch(connection->parser_state){ switch(connection->parser_state){
case AVRCP_PARSER_GET_ATTRIBUTE_HEADER:{ case AVRCP_PARSER_GET_ATTRIBUTE_HEADER:{
if (connection->parser_attribute_header_pos < AVRCP_BROWSING_ITEM_HEADER_LEN) {
connection->parser_attribute_header[connection->parser_attribute_header_pos++] = byte; connection->parser_attribute_header[connection->parser_attribute_header_pos++] = byte;
break; if (connection->parser_attribute_header_pos < AVRCP_BROWSING_ITEM_HEADER_LEN) break;
}
uint16_t attribute_total_value_len = big_endian_read_16(connection->parser_attribute_header, 1); uint16_t attribute_total_value_len = big_endian_read_16(connection->parser_attribute_header, 1);
connection->parsed_attribute_value[connection->parsed_attribute_value_offset++] = connection->parser_attribute_header[0]; // prepend with item type connection->parsed_attribute_value[connection->parsed_attribute_value_offset++] = connection->parser_attribute_header[0]; // prepend with item type
connection->parsed_attribute_value_len = btstack_min(attribute_total_value_len, AVRCP_MAX_ATTRIBUTTE_SIZE - prepended_header_size); // reduce AVRCP_MAX_ATTRIBUTTE_SIZE for the size ot item type connection->parsed_attribute_value_len = btstack_min(attribute_total_value_len, AVRCP_MAX_ATTRIBUTTE_SIZE - prepended_header_size); // reduce AVRCP_MAX_ATTRIBUTTE_SIZE for the size ot item type