Opened 19 years ago
Closed 18 years ago
#1738 closed defect (bug) (duplicate)
Error in functions-post.php when $_SERVER['REMOTE_ADDR'] returns comma seperated list of IP addresses
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 1.5.2 |
Component: | General | Keywords: | |
Focuses: | Cc: |
Description
When certain users post comments, this error message is displayed:
Warning: gethostbyaddr(): Address is not a valid IPv4 or IPv6 address in /htdocs/wp-includes/functions-post.php on line 472
The problem is on this line in functions-post.php:
$user_domain = apply_filters('pre_comment_user_domain', gethostbyaddr($user_ip) );
The problem is that $_SERVERREMOTE_ADDR? can contain a comma separated list of IP addresses, which gethostbyaddr() will choke on. The code should be changed to the following:
$ips = explode(', ', $_SERVER['REMOTE_ADDR']); $user_domain = apply_filters('pre_comment_user_domain', gethostbyaddr($ips[0]);
This ensures that if there are multiple IPs, only the first one is used. (If there is only one IP in the list, explode returns an array with the input string, so this case will still work as well.)
Change History (2)
Note: See
TracTickets for help on using
tickets.
Marking a duplicate of #3197, as that one has a more recent patch.