{
struct avrcp_player *player = session->player;
struct media_player *mp = player->user_data;
- uint16_t id;
+ uint16_t id, namelen;
uint32_t subtype;
const char *curval, *strval;
char name[255];
avrcp_player_parse_features(player, &operands[8]);
- if (operands[26] != 0) {
- memcpy(name, &operands[27], operands[26]);
+ namelen = bt_get_be16(&operands[26]);
+ if (namelen > 0) {
+ namelen = MIN(namelen, sizeof(name) - 1);
+ memcpy(name, &operands[28], namelen);
+ name[namelen] = '\0';
media_player_set_name(mp, name);
}