otp538u: searching otp538u_vt_table could overflow array bounds

defect #341

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
Jon Trulson 2015-06-10 15:00:59 -06:00 committed by Mihai Tudor Panu
parent 0bab36a95a
commit a41f59984f

View File

@ -163,7 +163,7 @@ float OTP538U::objectTemperature()
// add +2 to compensate for the -20C and -10C slots below zero
int voltOffset = int(ambTemp / 10) + 1 + 2;
float voltage = sensorVolts * 10.0;
for (slot=0; slot<otp538u_vt_table_max; slot++)
for (slot=0; slot<(otp538u_vt_table_max - 1); slot++)
{
if ( (voltage > otp538u_vt_table[slot][voltOffset]) &&
(voltage < otp538u_vt_table[slot+1][voltOffset]) )