sound trigger: fix array overflow in HAL wrapper

Bug: 65383689
Test: make
Change-Id: I9d62eb9be096222bcc3e1734a21f6ade0005b180
This commit is contained in:
Eric Laurent 2017-09-07 12:35:29 -07:00
parent 1a17e86d76
commit a6920307f1

View file

@ -388,10 +388,12 @@ void SoundTriggerHalImpl::convertTriggerPhraseToHal(
halTriggerPhrase->id = triggerPhrase->id;
halTriggerPhrase->recognition_mode = triggerPhrase->recognitionModes;
unsigned int i;
for (i = 0; i < triggerPhrase->users.size(); i++) {
halTriggerPhrase->num_users =
std::min((int)triggerPhrase->users.size(), SOUND_TRIGGER_MAX_USERS);
for (i = 0; i < halTriggerPhrase->num_users; i++) {
halTriggerPhrase->users[i] = triggerPhrase->users[i];
}
halTriggerPhrase->num_users = i;
strlcpy(halTriggerPhrase->locale,
triggerPhrase->locale.c_str(), SOUND_TRIGGER_MAX_LOCALE_LEN);