php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25342 function gethostbynamel. This is returning ip addresses for invalid domains
Submitted: 2003-09-01 07:09 UTC Modified: 2003-09-01 17:20 UTC
From: getsuryya at rediffmail dot com Assigned:
Status: Not a bug Package: *Network Functions
PHP Version: 4.3.2 OS: LINUX
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: getsuryya at rediffmail dot com
New email:
PHP Version: OS:

 

 [2003-09-01 07:09 UTC] 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 )

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-09-01 17:20 UTC] pollita@php.net
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


 [2013-08-20 15:47 UTC] daverandom@php.net
Automatic comment from SVN on behalf of daverandom
Revision: http://svn.php.net/viewvc/?view=revision&revision=331178
Log: As DEFAULT is a reserved words, the constant for default strength is Collator::DEFAULT_STRENGTH, not Collator::DEFAULT.

--
Provided by anonymous #25342 ()
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Dec 06 07:01:25 2019 UTC