php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71675 gethostbyname not return unmodified hostname
Submitted: 2016-02-26 23:09 UTC Modified: 2016-02-27 01:11 UTC
From: spacek at best-net dot cz Assigned:
Status: Not a bug Package: Network related
PHP Version: 7.0.3 OS: Unix
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
31 - 18 = ?
Subscribe to this entry?

 
 [2016-02-26 23:09 UTC] spacek at best-net dot cz
Description:
------------
Function gethostbyname() not return unmodified hostname in situation when the input string contains only numbers.

Tested in:
PHP 7.0.3
PHP 5.6.18

Test script:
---------------
<?php

echo gethostbyname('1111111').PHP_EOL;
echo gethostbyname('111').PHP_EOL;
echo gethostbyname('111.111').PHP_EOL;
echo gethostbyname('111768768768768768.com').PHP_EOL;
echo gethostbyname('a111').PHP_EOL;
echo gethostbyname('foo').PHP_EOL;

Expected result:
----------------
1111111
111
111.111
111768768768768768.com
a111
foo

Actual result:
--------------
0.16.244.71
0.0.0.111
111.0.0.111
111768768768768768.com
a111
foo

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-02-27 01:11 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2016-02-27 01:11 UTC] requinix@php.net
This is how gethostbyname(3) behaves.
http://linux.die.net/man/3/gethostbyname

For numeric inputs, the behavior is explained in the inet_addr(3) docs.
http://linux.die.net/man/3/inet_addr

See your distro's documentation for more specific information.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 18:01:28 2024 UTC