mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-24 12:07:28 +08:00
fix: validate random_int parameters in Helper::randomPort to prevent min > max error
This commit is contained in:
@@ -142,8 +142,13 @@ class Helper
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function randomPort($range): int {
|
public static function randomPort($range): int {
|
||||||
$portRange = explode('-', $range);
|
$portRange = explode('-', (string) $range, 2);
|
||||||
return random_int((int)$portRange[0], (int)$portRange[1]);
|
$min = (int) ($portRange[0] ?? 0);
|
||||||
|
$max = (int) ($portRange[1] ?? $portRange[0] ?? 0);
|
||||||
|
if ($min > $max) {
|
||||||
|
[$min, $max] = [$max, $min];
|
||||||
|
}
|
||||||
|
return random_int($min, $max);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function base64EncodeUrlSafe($data)
|
public static function base64EncodeUrlSafe($data)
|
||||||
|
|||||||
Reference in New Issue
Block a user