Skip to content

Commit bac84d1

Browse files
committed
don't cast strings exceeding the min/max int ranges
1 parent 4d7cc32 commit bac84d1

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/Symfony/Bridge/Doctrine/Form/ChoiceList/ORMQueryBuilderLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function getEntitiesByIds(string $identifier, array $values): array
6767

6868
// Filter out non-integer values (e.g. ""). If we don't, some
6969
// databases such as PostgreSQL fail.
70-
$values = array_values(array_filter($values, fn ($v) => (string) $v === (string) (int) $v || ctype_digit($v)));
70+
$values = array_values(array_filter($values, static fn ($v) => \is_string($v) && ctype_digit($v) || (string) $v === (string) (int) $v));
7171
} elseif (\in_array($type, ['ulid', 'uuid', 'guid'])) {
7272
$parameterType = class_exists(ArrayParameterType::class) ? ArrayParameterType::STRING : Connection::PARAM_STR_ARRAY;
7373

src/Symfony/Component/Yaml/Inline.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,10 @@ private static function evaluateScalar(string $scalar, int $flags, array &$refer
701701
switch (true) {
702702
case ctype_digit($scalar):
703703
case '-' === $scalar[0] && ctype_digit(substr($scalar, 1)):
704+
if ($scalar < \PHP_INT_MIN || \PHP_INT_MAX < $scalar) {
705+
return $scalar;
706+
}
707+
704708
$cast = (int) $scalar;
705709

706710
return ($scalar === (string) $cast) ? $cast : $scalar;

0 commit comments

Comments
 (0)