|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68081 checkdnsrr( '' ) returns `true` when no MX, only CNAME
Submitted: 2014-09-23 03:52 UTC Modified: 2017-10-24 08:12 UTC
Avg. Score:3.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: figureonecpr at gmail dot com Assigned:
Status: Open Package: Network related
PHP Version: master-Git-2014-09-23 (snap) OS: Linux Phoenix 2.6.32
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: figureonecpr at gmail dot com
New email:
PHP Version: OS:


 [2014-09-23 03:52 UTC] figureonecpr at gmail dot com
Per, checkdnsrr() defaults to an MX record query when the second argument is not supplied.  Regardless of SMTP's implicit MX logic, this function is supposed to return `false` if $host does not have at least one *explicit* MX in the DNS.

However, if the supplied hostname simply has a CNAME record (a good CNAME, one that can be dereferenced to an extant canonical hostname) the function returns `true`.  

The bug is seen regardless of whether the canonical hostname itself has an MX record.   For example, if you have CNAME --> A and do checkdnsrr( '' ) you will get `true`.  But if you go straight to the canonical A record and do checkdnsrr( '' ) you will get `false`.

Test script:
// where exists is a CNAME in the DNS pointing to an extant canonical hostname

var_dump( checkdnsrr( '' ) );

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-09-23 04:54 UTC]
-Assigned To: +Assigned To: kriscraig
 [2014-09-23 04:56 UTC]
Could you include the actual hostname you used?  That'll make it easier for me to repro.


 [2014-09-23 07:19 UTC] figureonecpr at gmail dot com
You can use

at present.
 [2014-09-23 18:44 UTC] figureonecpr at gmail dot com
Note the dn does the same thing with other RRtypes: treats the existence of a CNAME as a positive result.  This bug cripples the function into unusability.  
The example I also posted to the mailing list is that checkdnsrr( '', 'SRV' ) returns `true`.  And you do not have an SRV record (as a Windows guy I would've been surprised if you did!).
 [2017-10-24 08:12 UTC]
-Status: Assigned +Status: Open -Assigned To: kriscraig +Assigned To:
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed Oct 28 06:01:23 2020 UTC