Integer Overflow in sprintf Buffer

This commit is contained in:
2025-12-07 19:01:13 +01:00
parent 46e8dae697
commit f303f9f032
2 changed files with 3 additions and 3 deletions

View File

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