php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #1894 gethostbyname returns "255.255.255.255"
Submitted: 1999-07-27 13:42 UTC Modified: 2002-06-16 08:35 UTC
From: pete dot nelson at ci dot stpaul dot mn dot us Assigned:
Status: Not a bug Package: Misbehaving function
PHP Version: 3.0.11 OS: SGI Irix 6.2
Private report: No CVE-ID: None
 [1999-07-27 13:42 UTC] pete dot nelson at ci dot stpaul dot mn dot us
I wanted to make a hostname lookup page, and realized that it couldn't be done 
on either of my SGI indys.  It works fine under RedHat linux, Win98 & WinNT (all 
running apache 1.3.6).  My guess is a bug in the SGI system libraries - it does get a little nutty.

Here's my script:

<html><head><title>Host Checker</title></head>
<body bgcolor=white>
<h1>Test a Host</h1>

<?php
  if(! isset($host)) { $host = "friday"; }

// The Input:
  echo "<form action=\"http-check.php3\" method=post>";
  echo "<input type=text name=host size=30 value=\"$host\">";
  echo "<input type=submit value=\"Check Host\">";
  echo "</form>";

// Check DNS
  $ip = gethostbyname($host);
  echo "<h2>DNS Entry for <font size=+3 color=blue>$host</font></h2>\n";
  echo "<b>$host:</b> $ip\n";
// The HTTP Request:
  echo "<p><hr align=center width=85%>";
  echo "<h2>HTTP Response from <font size=+3 color=blue>$host</font></h2>\n";

  $fp = fsockopen("$ip", 80, &$errnr, &$errstr); 
  if(! $fp) {
    echo "<h1><font color=red>Error!</font></h1>";
    echo "<p>$errstr ($errnr)";
    exit;
    }

  fputs($fp, "HEAD / HTTP/1.0\n\n");

// The HTTP Response:
  while(!$end) {
    $line = fgets($fp, 2048);
    if(trim($line) == "") { $end = true; }
    else { echo "<BR>$line"; }
    }
  fclose($fp);

?>

</body></html>    

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-07-29 16:21 UTC] pete dot nelson at ci dot stpaul dot mn dot us
Seems to be a problem with the memcpy function used in functions/dns.c (line 180 in v3.0.11).
Test of the function confirm - the same C code works on Linux & Windows (gcc), but returns 255.255.255.255 on my Irix boxes.
 [1999-11-11 19:38 UTC] joey at cvs dot php dot net
Seems unlikely that this is related to memcpy, but I am not a C guru. Can you verify
that bug is still there (a/o 3.0.12?) If I had access to an SGI box, I'd do it...
 [2002-06-16 08:35 UTC] sander@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately, PHP 3 is no longer supported. Please download
the latest version of PHP 4 from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sun May 26 21:01:26 2019 UTC