Skip to content
Snippets Groups Projects
Commit 25147d97 authored by Andrey Vitushkin's avatar Andrey Vitushkin
Browse files

Issue #3466565: If a syntactically invalid default gateway is entered, an...

Issue #3466565: If a syntactically invalid default gateway is entered, an error will occur in the MySQL environment
parent 05bba025
No related branches found
No related tags found
No related merge requests found
Pipeline #246742 failed
......@@ -65,13 +65,24 @@ final class MySqlFormatConstraintValidator extends ConstraintValidator {
return;
}
/** @var \IPTools\Range $hosts */
$hosts = Network::parse($value)->hosts;
// As in the "ipaddress_mysql" widget and in the IpAddressMySql @FeedsTarget
// plugin we applied to the value the inet_pton() function, then we need to
// convert it back to the human-readable representation.
$defaultGateway = inet_ntop($field->default_gateway);
/** @var \IPTools\Range $hosts */
$hosts = Network::parse($value)->hosts;
// If a syntactically invalid Default Gateway was given then inet_pton()
// return false. So we should check this first.
if ($field->default_gateway) {
$defaultGateway = inet_ntop($field->default_gateway);
}
else {
$this->context->addViolation($constraint->defaultGateway, [
'@firstIP' => (string) $hosts->getFirstIP(),
'@lastIP' => (string) $hosts->getLastIP(),
]);
return;
}
try {
/** @var \IPTools\IP $ipAddress */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment