ID: 25487
Updated by: [email][/email]
Reported By: ckruse at wwwtech dot de
-Status: Assigned
+Status: Wont fix
Bug Type: Network related
Operating System: All
PHP Version: 4.3.3
Assigned To: iliaa
New Comment:

ip2long() cannot return FALSE because it would break backwards
compatibility. This in turn makes changing inet_addr() to inet_aton(),
which is not avaliable on all systems pointless.

Previous Comments:

[2003-09-11 06:31:10] ckruse at wwwtech dot de

PHP uses in the ip2long() function the obsolete inet_addr() interface
which makes it impossible to detect errors in the input values:
inet_addr() converts to -1, which is correct. But in
error case it also returns INADDR_NONE, wich is usually defined as -1.
Therefore the inet_aton() function should be used. I made a little
patch which corrects this.

Actual result:
> struct in_addr in;
< RETURN_LONG(ntohl(inet_addr(Z_STRVAL_PP(str))));
> if(inet_aton(Z_STRVAL_PP(str),&inp) == 0) {
> php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid address");
> }
> RETURN_LONG(ntohl(inp.s_addr));


Edit this bug report at [url][/url]