diff options
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | ext/standard/dns.c | 5 | ||||
-rw-r--r-- | ext/standard/tests/network/dns_get_record_caa.phpt | 41 |
3 files changed, 30 insertions, 18 deletions
@@ -162,6 +162,8 @@ PHP NEWS used). (Anton Artamonov) - Standard: + . Fixed bug #75916 (DNS_CAA record results contain garbage). (Mike, + Philip Sharp) . Fixed unserialize(), to disable creation of unsupported data structures through manually crafted strings. (Dmitry) . Fixed bug #75409 (accept EFAULT in addition to ENOSYS as indicator diff --git a/ext/standard/dns.c b/ext/standard/dns.c index 6fe2a784eb..614bc32119 100644 --- a/ext/standard/dns.c +++ b/ext/standard/dns.c @@ -546,7 +546,10 @@ static u_char *php_parserr(u_char *cp, u_char *end, querybuf *answer, int type_t CHECKCP(n); add_assoc_stringl(subarray, "tag", (char*)cp, n); cp += n; - add_assoc_string(subarray, "value", (char*)cp); + n = dlen - n - 2; + CHECKCP(n); + add_assoc_stringl(subarray, "value", (char*)cp, n); + cp += n; break; case DNS_T_TXT: { diff --git a/ext/standard/tests/network/dns_get_record_caa.phpt b/ext/standard/tests/network/dns_get_record_caa.phpt index 121bb92ae7..21286921e1 100644 --- a/ext/standard/tests/network/dns_get_record_caa.phpt +++ b/ext/standard/tests/network/dns_get_record_caa.phpt @@ -7,25 +7,32 @@ if (getenv("SKIP_ONLINE_TESTS")) die("skip online test"); ?> --FILE-- <?php -/* This must be a domain that publishes an RFC6844 CAA-type DNS record */ -$domain = 'google.com'; -$match = false; -$dns = dns_get_record($domain, DNS_CAA); -if (count($dns) > 0) { - if (array_key_exists('type', $dns[0]) - and $dns[0]['type'] == 'CAA' - and array_key_exists('flags', $dns[0]) - and array_key_exists('tag', $dns[0]) - and array_key_exists('value', $dns[0]) - ) { - $match = true; +/* This must be domains which publish an RFC6844 CAA-type DNS record */ +$domains = ["big.basic.caatestsuite.com", "google.com"]; +foreach ($domains as $domain) { + $match = false; + $dns = dns_get_record($domain, DNS_CAA); + if (count($dns) > 0) { + if (array_key_exists("type", $dns[0]) + and $dns[0]["type"] == "CAA" + and array_key_exists("flags", $dns[0]) + and array_key_exists("tag", $dns[0]) + and array_key_exists("value", $dns[0]) + ) { + $chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-."; + if (strlen($dns[0]["value"]) == strspn($dns[0]["value"], $chars)) { + $match = true; + } + } + } + if ($match) { + echo "CAA record found\n"; + } else { + echo "CAA lookup failed\n"; + var_dump($dns); } -} -if ($match) { - echo "CAA record found\n"; -} else { - echo "CAA Lookup failed\n"; } ?> --EXPECT-- CAA record found +CAA record found |