[PATCH] fix gethostbyname() to return false when hostname not resolved

From: Date: Tue, 25 Sep 2001 20:56:28 +0000
Subject: [PATCH] fix gethostbyname() to return false when hostname not resolved
Groups: php.dev 
Request: Send a blank email to php-dev+get-66599@lists.php.net to get a copy of this message
here's a patch to fix bug #13423. think anyone is relying on the current (vastly lame, imho) behavior? jim Index: ext/standard/dns.c =================================================================== RCS file: /repository/php4/ext/standard/dns.c,v retrieving revision 1.35 diff -u -r1.35 dns.c --- ext/standard/dns.c 19 Sep 2001 18:08:15 -0000 1.35 +++ ext/standard/dns.c 25 Sep 2001 20:54:06 -0000 @@ -135,6 +135,7 @@ PHP_FUNCTION(gethostbyname) { zval **arg; + char *host; if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) { ZEND_WRONG_PARAM_COUNT(); @@ -142,7 +143,12 @@ convert_to_string_ex(arg); - RETVAL_STRING(php_gethostbyname(Z_STRVAL_PP(arg)), 0); + if ((host = php_gethostbyname(Z_STRVAL_PP(arg)))) { + RETVAL_STRING(host, 0); + } + else { + RETURN_FALSE; + } } /* }}} */ @@ -186,7 +192,7 @@ hp = gethostbyname(name); if (!hp || !hp->h_addr_list) { - return estrdup(name); + return NULL; } memcpy(&in.s_addr, *(hp->h_addr_list), sizeof(in.s_addr));

« previous php.dev (#66599) next »