1
0
mirror of https://github.com/danog/dns.git synced 2024-11-26 20:14:51 +01:00

Remove error suppression from calls to inet_pton()

This commit is contained in:
Aaron Piotrowski 2023-01-09 17:10:52 -06:00
parent 28383c051f
commit 12a4b46ba7
No known key found for this signature in database
GPG Key ID: 5B456E6AABA44A63
5 changed files with 5 additions and 5 deletions

View File

@ -169,7 +169,7 @@ final class DnsConfig
$addr = \trim($addr, "[]");
$port = (int) $port;
if (!@\inet_pton($addr)) {
if (!\inet_pton($addr)) {
throw new DnsConfigException("Invalid server IP: $addr");
}

View File

@ -36,7 +36,7 @@ final class HostLoader
$parts = \preg_split('/\s+/', $line);
if (!($ip = @\inet_pton($parts[0]))) {
if (!($ip = \inet_pton($parts[0]))) {
continue;
}

View File

@ -439,7 +439,7 @@ final class Rfc1035StubDnsResolver implements DnsResolver
private function normalizeName(string $name, int $type): string
{
if ($type === DnsRecord::PTR) {
if (($packedIp = @\inet_pton($name)) !== false) {
if (($packedIp = \inet_pton($name)) !== false) {
if (isset($packedIp[4])) { // IPv6
$name = \wordwrap(\strrev(\bin2hex($packedIp)), 1, ".", true) . ".ip6.arpa";
} else { // IPv4

View File

@ -71,7 +71,7 @@ final class UnixDnsConfigLoader implements DnsConfigLoader
}
$value = \trim($value);
$ip = @\inet_pton($value);
$ip = \inet_pton($value);
if ($ip === false) {
continue;
}

View File

@ -63,7 +63,7 @@ final class WindowsDnsConfigLoader implements DnsConfigLoader
// Microsoft documents space as delimiter, AppVeyor uses comma, we just accept both
foreach (\explode(" ", \strtr($nameserver, ",", " ")) as $nameserver) {
$nameserver = \trim($nameserver);
$ip = @\inet_pton($nameserver);
$ip = \inet_pton($nameserver);
if ($ip === false) {
continue;