#25342 [Opn->Bgs]: function gethostbynamel. This is returning ip addresses for invalid domains

From: Date: Mon, 01 Sep 2003 22:20:10 +0000
Subject: #25342 [Opn->Bgs]: function gethostbynamel. This is returning ip addresses for invalid domains
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-47026@lists.php.net to get a copy of this message
ID: 25342 Updated by: pollita@php.net Reported By: getsuryya at rediffmail dot com -Status: Open +Status: Bogus Bug Type: *Network Functions Operating System: LINUX PHP Version: 4.3.2 New Comment: The actual result you reported for case #2 is the expected result according to the yahoo.com name servers. I cannot, however, reproduce the bug you reported for case #1. The most common cause for receiving errorneous IPs in such a case is having a search domain configured for your system's resolver library. i.e.: looking up 'com' may be attempting to resolve 'com.yourdomain.com' which may indeed be valid if yourdomain.com is configured with a wildcard. Check /etc/resolv.conf Previous Comments: ------------------------------------------------------------------------ [2003-09-01 07:09:37] getsuryya at rediffmail dot com Description: ------------ The bug is in the function gethostbynamel. When a domain name is passed to it as an argument then it should return the associated ip addresses of this domain in an array, this is working properly in version 4.3.1. But in version 4.3.2 the bugs are as under. 1)It is returning an ip for a domain name which is not valid, where as it should have returned false in case of non valid domain name. 2)It is only returning a single ip associated with the domain, not all the ip addresses. Reproduce code: --------------- #CODE FOR CASE 1 if($hosts = gethostbynamel('com')){ print_r($hosts); }else{ print "Invalid domain"; } #CODE FOR CASE 2 if($hosts = gethostbynamel('yahoo.com')){ print_r($hosts); }else{ print "Invalid domain"; Expected result: ---------------- #EXPECTED RESULT FOR CASE 1 Invalid domain #EXPECTED RESULT FOR CASE 2 Array ( [0] => 216.109.118.76 [1] => 216.109.118.77 [2] => 216.109.118.78 [3] => 216.109.118.65 [4] => 216.109.118.69 [5] => 216.109.118.71 [6] => 216.109.118.72 [7] => 216.109.118.74 ) Actual result: -------------- #ACTUAL RESULT FOR CASE 1 Array ( [0] => 206.16.0.134 ) #ACTUAL RESULT FOR CASE 2 Array ( [0] => 66.218.71.198 ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=25342&edit=1

« previous php.bugs (#47026) next »