Missing Bounds Check on Array Access

This commit is contained in:
2025-12-07 20:27:56 +01:00
parent 4afc155230
commit c7d37b1d95

View File

@ -62,6 +62,10 @@ string Drive::sCapacityToText()
dSize /= 1000; dSize /= 1000;
u16UnitIndex++; u16UnitIndex++;
} }
if (u16UnitIndex >= 9)
{
u16UnitIndex = 8;
}
int precision = (u16UnitIndex >= 3) ? (u16UnitIndex - 3) : 0; int precision = (u16UnitIndex >= 3) ? (u16UnitIndex - 3) : 0;
sprintf(acBuffer, "%.*f %s", precision, dSize, units[u16UnitIndex]); sprintf(acBuffer, "%.*f %s", precision, dSize, units[u16UnitIndex]);
return acBuffer; return acBuffer;