MDL-71487 admin: ensure filesize settings don't overflow integer.

This commit is contained in:
Paul Holden 2021-04-28 20:05:16 +01:00
parent 0d0e66d37c
commit fdbbef6372

View File

@ -126,6 +126,7 @@ class filesize extends \admin_setting {
if (is_null($bytes)) {
return null;
}
$bytes = intval($bytes);
return self::parse_bytes($bytes);
}
@ -145,9 +146,10 @@ class filesize extends \admin_setting {
return get_string('errorsetting', 'admin');
}
// Calculate size in bytes, ensuring we don't overflow PHP_INT_MAX.
$bytes = $data['v'] * $data['u'];
$result = (is_int($bytes) && $this->config_write($this->name, $bytes));
$result = $this->config_write($this->name, $bytes);
return ($result ? '' : get_string('errorsetting', 'admin'));
}