mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-79539 core: handling negative input to get the upper value
Co-authored-by: Alain Corbière <alain.corbiere@univ-lemans.fr>
This commit is contained in:
parent
c29a812323
commit
15c7909885
@ -458,12 +458,27 @@ class address_manager {
|
||||
* @return string The encoded binary data
|
||||
*/
|
||||
protected function pack_int($int) {
|
||||
// If PHP environment is running on a 64-bit.
|
||||
if (PHP_INT_SIZE === 8) {
|
||||
$l = intdiv($int, pow(2, 32)); // 32-bit integer quotient.
|
||||
$r = $int % pow(2, 32); // 32-bit integer remaining.
|
||||
// Will be used to ensures that the result remains as a 32-bit unsigned integer and
|
||||
// doesn't extend beyond 32 bits.
|
||||
$notation = 0xffffffff;
|
||||
|
||||
if ($int < 0) {
|
||||
// If the given integer is negative, set it to -1.
|
||||
$l = -1;
|
||||
} else {
|
||||
// Otherwise, calculate the upper 32 bits of the 64-bit integer.
|
||||
$l = ($int >> 32) & $notation;
|
||||
}
|
||||
|
||||
// Calculate the lower 32 bits of the 64-bit integer.
|
||||
$r = $int & $notation;
|
||||
|
||||
// Pack the values of $l (upper 32 bits) and $r (lower 32 bits) into a binary string format.
|
||||
return pack('NN', $l, $r);
|
||||
} else {
|
||||
// Pack the values into a binary string format.
|
||||
return pack('NN', 0, $int);
|
||||
}
|
||||
}
|
||||
|
@ -3099,5 +3099,12 @@ privatefiles,moodle|/user/files.php';
|
||||
upgrade_main_savepoint(true, 2022112805.03);
|
||||
}
|
||||
|
||||
if ($oldversion < 2022112805.13) {
|
||||
// Delete datakey with datavalue -1.
|
||||
$DB->delete_records('messageinbound_datakeys', ['datavalue' => '-1']);
|
||||
// Main savepoint reached.
|
||||
upgrade_main_savepoint(true, 2022112805.13);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$version = 2022112805.12; // 20221128 = branching date YYYYMMDD - do not modify!
|
||||
$version = 2022112805.13; // 20221128 = branching date YYYYMMDD - do not modify!
|
||||
// RR = release increments - 00 in DEV branches.
|
||||
// .XX = incremental changes.
|
||||
$release = '4.1.5+ (Build: 20230929)'; // Human-friendly version name
|
||||
|
Loading…
x
Reference in New Issue
Block a user