Bug #52260 [NEW]: Windows implementation of dns_get_record fails with non-existing domain

From: Date: Tue, 06 Jul 2010 00:08:27 +0000
Subject: Bug #52260 [NEW]: Windows implementation of dns_get_record fails with non-existing domain
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-152121@lists.php.net to get a copy of this message
From:             
Operating system: Windows (All)
PHP version:      5.3.2
Package:          Network related
Bug Type:         Bug
Bug description:Windows implementation of dns_get_record fails with non-existing domain

Description:
------------
Windows implementation of dns_get_record fails with non-existing domain

---
var_dump(dns_get_record('dalfkjdaslfj.net')); // return false, throw
E_WARNING
---

This is inconsistent with the *NIX implementation, which never (in our
testing, see * note at bottom) throws E_WARNING on a non-existing domain,
and returns an empty array, as demonstrated below:

---
afischer@miraculix:~$ php -v
PHP 5.3.2-1ubuntu4.2 with Suhosin-Patch (cli) (built: May 13 2010
20:01:00)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with Xdebug v2.0.5, Copyright (c) 2002-2008, by Derick Rethans

afischer@miraculix:~$ php -r "error_reporting(E_ALL);
var_dump(dns_get_record('dalfkjdaslfj.net'));"
array(0) {
}
---

There is code in dns_win32.c to attempt to catch some cases of non-existing
domains, but it does not seem to be complete.

Changing
---
		if (status) {
				if (status == DNS_INFO_NO_RECORDS) {
					continue;
---
to 
---
			if (status) {
				if (status == DNS_INFO_NO_RECORDS || status ==
DNS_ERROR_RCODE_NAME_ERROR) {
					continue;

---
Seems to fix the problems for me.  For reference, all error codes which can
be returned by DNSQuery_A are listed by Microsoft:
http://msdn.microsoft.com/en-us/library/ms681391

* I cannot say for sure if reports like
http://bugs.php.net/bug.php?id=50903 are valid. 
I do know from reading the
PHP source that there are three separate *NIX implementations of
php_dns_search(), but Andreas has not investigated which one his Ubuntu
server is using.  It seems likely that this inconsistency affects NIX
implementations as well.

Test script:
---------------
<?php
var_dump(dns_get_record('dalfkjdaslfj.net')); // return false, throw
E_WARNING
?>

Expected result:
----------------
array(0) {
}

Actual result:
--------------
bool(false)

-- 
Edit bug report at http://bugs.php.net/bug.php?id=52260&edit=1
-- 
Try a snapshot (PHP 5.2):            http://bugs.php.net/fix.php?id=52260&r=trysnapshot52
Try a snapshot (PHP 5.3):            http://bugs.php.net/fix.php?id=52260&r=trysnapshot53
Try a snapshot (trunk):              http://bugs.php.net/fix.php?id=52260&r=trysnapshottrunk
Fixed in SVN:                        http://bugs.php.net/fix.php?id=52260&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=52260&r=needdocs
Fixed in release:                    http://bugs.php.net/fix.php?id=52260&r=alreadyfixed
Need backtrace:                      http://bugs.php.net/fix.php?id=52260&r=needtrace
Need Reproduce Script:               http://bugs.php.net/fix.php?id=52260&r=needscript
Try newer version:                   http://bugs.php.net/fix.php?id=52260&r=oldversion
Not developer issue:                 http://bugs.php.net/fix.php?id=52260&r=support
Expected behavior:                   http://bugs.php.net/fix.php?id=52260&r=notwrong
Not enough info:                     http://bugs.php.net/fix.php?id=52260&r=notenoughinfo
Submitted twice:                     http://bugs.php.net/fix.php?id=52260&r=submittedtwice
register_globals:                    http://bugs.php.net/fix.php?id=52260&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=52260&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=52260&r=dst
IIS Stability:                       http://bugs.php.net/fix.php?id=52260&r=isapi
Install GNU Sed:                     http://bugs.php.net/fix.php?id=52260&r=gnused
Floating point limitations:          http://bugs.php.net/fix.php?id=52260&r=float
No Zend Extensions:                  http://bugs.php.net/fix.php?id=52260&r=nozend
MySQL Configuration Error:           http://bugs.php.net/fix.php?id=52260&r=mysqlcfg



Thread (5 messages)

« previous php.bugs (#152121) next »