|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-09-12 00:07 UTC] iliaa@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 13:00:01 2025 UTC |
Description: ------------ 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 255.255.255.255 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: -------------- 1223a1224 > struct in_addr in; 1231c1232,1237 < 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_NULL(); > } > > RETURN_LONG(ntohl(inp.s_addr));