32bit > 4GB integer overflow edge case fix

This commit is contained in:
Abel Barrera Duran 2020-12-19 14:00:07 -05:00
parent b749a3a421
commit 52979da973

View File

@ -51,8 +51,8 @@ func (mc MemCheck) Check() (warnings, errorList []error) {
errorList = append(errorList, errors.Wrapf(err, "failed to get system info")) errorList = append(errorList, errors.Wrapf(err, "failed to get system info"))
} }
// Totalram returns bytes; convert to MB // Totalram holds the total usable memory. Unit holds the size of a memory unit in bytes. Multiply them and convert to MB
actual := uint64(info.Totalram) / 1024 / 1024 actual := uint64(info.Totalram) * uint64(info.Unit) / 1024 / 1024
if actual < mc.Mem { if actual < mc.Mem {
errorList = append(errorList, errors.Errorf("the system RAM (%d MB) is less than the minimum %d MB", actual, mc.Mem)) errorList = append(errorList, errors.Errorf("the system RAM (%d MB) is less than the minimum %d MB", actual, mc.Mem))
} }