[php-src] Issue #10518: dns_get_record broken records when querying TXT records on Debian/Alpine

From: Date: Mon, 06 Feb 2023 13:22:56 +0000
Subject: [php-src] Issue #10518: dns_get_record broken records when querying TXT records on Debian/Alpine
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-243656@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/10518 Author: mlocati ### Description The following code: ```php <?php function dumpRecords(string $domain): void { echo "## {$domain}\n"; $records = dns_get_record($domain, DNS_TXT); if ($records === false) { echo "dns_get_records() failed!\n"; } else { $numFound = 0; foreach ($records as $record) { $subject = $record['txt'] . implode('', $record['entries']); if (strpos($subject, 'v=spf1') !== false || strpos($subject, 'google-site-verification=') !== false) { echo json_encode([ 'txt' => $record['txt'], 'entries' => $record['entries'], ], JSON_PRETTY_PRINT), "\n"; $numFound++; } } echo "Number of records found: {$numFound}\n"; } } dumpRecords('bbc.co.uk'); dumpRecords('mxtoolbox.com'); ``` Resulted in this output in Debian and Alpine (using the php:8.2-cli and php:8.2-cli-alpine Docker images): ``` ## bbc.co.uk Warning: dns_get_record(): A temporary server error occurred. in test.php on line 6 dns_get_records() failed! ## mxtoolbox.com { "txt": "google-site-verification=a72lcHiaH48r427O4d4O6SrvOBQkmH4IGZ98mH9YWwUlml8nrmxdc063ms0skf3bnvm2zvslffzv=spf1 redirect=mxtoolbox.com.hosted.spf-report.com", "entries": [ "google-site-verification=a72lcHiaH48r427O4d4O6SrvOBQkmH4IGZ98mH9YWwU", "lml8nrmxdc063ms0skf3bnvm2zvslffz", "v=spf1 redirect=mxtoolbox.com.hosted.spf-report.com" ] } Number of records found: 1 ``` But I expected this output instead (seen on Windows): ``` ## bbc.co.uk { "txt": "v=spf1 a ip4:212.58.224.0\/19 ip4:132.185.0.0\/16 ip4:78.136.53.80\/28 ip4:78.136.14.192\/27 ip4:78.136.19.8\/29 ip4:89.234.10.72\/29 ip4:89.234.53.236 ip4:212.111.33.181 ip4:78.137.117.8 ip4:46.37.176.74 ip4:185.184.237.181 ip4:185.119.233.144\/30 ip4:185.119.232.158 +include:sf.sis.bbc.co.uk +include:spf.messagelabs.com ~all", "entries": [ "v=spf1 a ip4:212.58.224.0\/19 ip4:132.185.0.0\/16 ip4:78.136.53.80\/28 ip4:78.136.14.192\/27 ip4:78.136.19.8\/29 ip4:89.234.10.72\/29 ip4:89.234.53.236 ip4:212.111.33.181 ip4:78.137.117.8 ip4:46.37.176.74 ip4:185.184.237.181", " ip4:185.119.233.144\/30 ip4:185.119.232.158 +include:sf.sis.bbc.co.uk +include:spf.messagelabs.com ~all" ] } { "txt": "google-site-verification=ITX3CwHXxGVfkCmhF4eSwdfo8h2ZGLAZ3zRpYvZi5XA", "entries": [ "google-site-verification=ITX3CwHXxGVfkCmhF4eSwdfo8h2ZGLAZ3zRpYvZi5XA" ] } { "txt": "google-site-verification=RaiMXJBIiFvqXHd43kv_ekzmXT2l8ibq5Xy0mulndvU", "entries": [ "google-site-verification=RaiMXJBIiFvqXHd43kv_ekzmXT2l8ibq5Xy0mulndvU" ] } Number of records found: 3 ## mxtoolbox.com { "txt": "google-site-verification=a72lcHiaH48r427O4d4O6SrvOBQkmH4IGZ98mH9YWwU", "entries": [ "google-site-verification=a72lcHiaH48r427O4d4O6SrvOBQkmH4IGZ98mH9YWwU" ] } { "txt": "v=spf1 redirect=mxtoolbox.com.hosted.spf-report.com", "entries": [ "v=spf1 redirect=mxtoolbox.com.hosted.spf-report.com" ] } Number of records found: 2 ``` Provided that nslookup provides the following results, I think the Windows output is ok, whereas the posix one is broken: ``` $ nslookup -type=TXT bbc.co.uk bbc.co.uk text = "miro-verification=1a94b0fef7a6d5136a272d5cb425e8dc034e8cfc" bbc.co.uk text = "_globalsign-domain-verification=AQ2dURU9RbDOuheuLrx89LSUlA_btgMS6vmFXngBtE" bbc.co.uk text = "v=spf1 a ip4:212.58.224.0/19 ip4:132.185.0.0/16 ip4:78.136.53.80/28 ip4:78.136.14.192/27 ip4:78.136.19.8/29 ip4:89.234.10.72/29 ip4:89.234.53.236 ip4:212.111.33.181 ip4:78.137.117.8 ip4:46.37.176.74 ip4:185.184.237.181" " ip4:185.119.233.144/30 ip4:185.119.232.158 +include:sf.sis.bbc.co.uk +include:spf.messagelabs.com ~all" bbc.co.uk text = "docusign=50f10407-e3e4-4f6a-aae4-712d4eb31329" bbc.co.uk text = "docusign=a10ad7b6-cf7e-472d-8157-23061f5b5116" bbc.co.uk text = "2RLXso9TrRPyhWOEhYggL0U/r1D+g8H7z9RqDBOmcJjSbj88TobGKimtkCrXZNBkDXQDj89lS4mDskNOJyWLdg==" bbc.co.uk text = "voUGv5zARbEV516E/S8Ugsy9/FOgDGg4n/rpmKZQRROVOj0+2tgzKw3Tk9+Ks6qVbNKU18KTrR5khxTQutDvBg==" bbc.co.uk text = "google-site-verification=ITX3CwHXxGVfkCmhF4eSwdfo8h2ZGLAZ3zRpYvZi5XA" bbc.co.uk text = "MS=ms10378910" bbc.co.uk text = "dropbox-domain-verification=l5djk65wpy3z" bbc.co.uk text = "adobe-idp-site-verification=9b850a4a56e3fac19aea1e0ac5db302e5cefab444cd73519dce1c72ccd4db058" bbc.co.uk text = "google-site-verification=RaiMXJBIiFvqXHd43kv_ekzmXT2l8ibq5Xy0mulndvU" bbc.co.uk text = "atlassian-domain-verification=SQsgJ5h/FqwMTXuSG/G4Nd1Gx6uX2keREOsZSa22D5XT46EsEuyaic8Aej4cR4Tr" bbc.co.uk text = "Huddle" bbc.co.uk text = "J0kgGm0XqA3/6pLD4DHeC5x/dAduzT809P1Iwx/PRCYvVS32rv75RIHKC2aVz47dJxKhPlxGf3h3KXiL6+dyXw==" bbc.co.uk text = "apple-domain-verification=jFFO0rdS9IrxgWUR" bbc.co.uk text = "msfpkey=69eew9c10ryb9cn8msgg2d4vg" bbc.co.uk text = "docker-verification=aab67462-78f7-4ade-a86b-358645923430" $ nslookup -type=TXT mxtoolbox.com mxtoolbox.com text = "google-site-verification=a72lcHiaH48r427O4d4O6SrvOBQkmH4IGZ98mH9YWwU" mxtoolbox.com text = "lml8nrmxdc063ms0skf3bnvm2zvslffz" mxtoolbox.com text = "v=spf1 redirect=mxtoolbox.com.hosted.spf-report.com" ``` Please remark that for Posix: 1. the query against bbc.co.uk fails consistently 2. the records of mxtoolbox.com are merged into one. ### PHP Version PHP 8.2.2 ### Operating System Windows / Debian / Alpine

« previous php.bugs (#243656) next »