mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02: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
9c4b38b8d5
commit
66e8bde8b3
3 changed files with 25 additions and 3 deletions
|
@ -456,12 +456,27 @@ class address_manager {
|
||||||
* @return string The encoded binary data
|
* @return string The encoded binary data
|
||||||
*/
|
*/
|
||||||
protected function pack_int($int) {
|
protected function pack_int($int) {
|
||||||
|
// If PHP environment is running on a 64-bit.
|
||||||
if (PHP_INT_SIZE === 8) {
|
if (PHP_INT_SIZE === 8) {
|
||||||
$l = intdiv($int, pow(2, 32)); // 32-bit integer quotient.
|
// Will be used to ensures that the result remains as a 32-bit unsigned integer and
|
||||||
$r = $int % pow(2, 32); // 32-bit integer remaining.
|
// 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);
|
return pack('NN', $l, $r);
|
||||||
} else {
|
} else {
|
||||||
|
// Pack the values into a binary string format.
|
||||||
return pack('NN', 0, $int);
|
return pack('NN', 0, $int);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3601,5 +3601,12 @@ privatefiles,moodle|/user/files.php';
|
||||||
upgrade_main_savepoint(true, 2023091300.03);
|
upgrade_main_savepoint(true, 2023091300.03);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($oldversion < 2023092900.01) {
|
||||||
|
// Delete datakey with datavalue -1.
|
||||||
|
$DB->delete_records('messageinbound_datakeys', ['datavalue' => '-1']);
|
||||||
|
// Main savepoint reached.
|
||||||
|
upgrade_main_savepoint(true, 2023092900.01);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
defined('MOODLE_INTERNAL') || die();
|
defined('MOODLE_INTERNAL') || die();
|
||||||
|
|
||||||
$version = 2023092900.00; // YYYYMMDD = weekly release date of this DEV branch.
|
$version = 2023092900.01; // YYYYMMDD = weekly release date of this DEV branch.
|
||||||
// RR = release increments - 00 in DEV branches.
|
// RR = release increments - 00 in DEV branches.
|
||||||
// .XX = incremental changes.
|
// .XX = incremental changes.
|
||||||
$release = '4.3beta+ (Build: 20230929)'; // Human-friendly version name
|
$release = '4.3beta+ (Build: 20230929)'; // Human-friendly version name
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue