guard against ADC buffer overrun (#1812)

This commit is contained in:
Matthew Kennedy 2020-09-21 02:37:51 -07:00 committed by GitHub
parent fccf0576bb
commit 2ee9e837bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -346,6 +346,11 @@ bool AdcDevice::isHwUsed(adc_channel_e hwChannelIndex) const {
}
void AdcDevice::enableChannel(adc_channel_e hwChannel) {
if (channelCount >= efi::size(values.adc_data)) {
firmwareError(OBD_PCM_Processor_Fault, "Too many ADC channels configured");
return;
}
int logicChannel = channelCount++;
size_t channelAdcIndex = hwChannel - 1;