|
[F] IP search bug when ip >= 128.0.0.0
|
|
09-08-2008, 10:22 PM
Post: #1
|
|||
|
|||
|
[F] IP search bug when ip >= 128.0.0.0
Environment (as reported in the AdminCP):
MyBB: 1.4.1 PHP: 5.2.6 DB: MySQLi 4.1.22 Bug: When you search an IP address using the ModCP (modcp.php?action=ipsearch) and the IP is bigger or equal than 128.0.0.0 (ie: the first byte is >= 128), it turns out that no post nor user is found (assuming that there are such ones registered in the DB, of course). The problem is with the call to the function fetch_longipv4_range in modcp.php, which it returns a negative integer number for IPs >= 128.0.0.0; and that number is compared with the field longipaddress or longregip in the DB. However, those fields seem to have a positive number, therefore no match is found. For example, in my forums, the page moderation.php?action=getip&pid=11 returns the IP 213.201.17.42 of that post. In the DB, I see the post in the posts table with these fields: ipadress = "213.201.17.42" and longipaddress = "2147483647". However, when I go to the page modcp.php?action=ipsearch&ipaddress=213.201.17.42&search_posts=1 then MyBB can't find any result. I hope you can solve this problem shortly. Thank you very much. |
|||
|
09-08-2008, 10:45 PM
Post: #2
|
|||
|
|||
|
RE: IP search bug when ip >= 128.0.0.0
Ah, the longipaddress column has a limit of 10, which is just enough for everything except the negative sign. This'll be fixed in 1.4.1
![]() My Blog - My Mods - My Site |
|||
|
09-08-2008, 10:55 PM
Post: #3
|
|||
|
|||
|
[F] IP search bug when ip >= 128.0.0.0
Thank you for your bug report.
This bug has been fixed in our internal code repository. Please note that the problem will not be fixed here until these forums are updated. ![]() My Blog - My Mods - My Site |
|||
|
09-08-2008, 11:02 PM
(This post was last modified: 09-08-2008 11:12 PM by Ryan Gordon.)
Post: #4
|
|||
|
|||
|
RE: [F] IP search bug when ip >= 128.0.0.0
Can you put this file in your main directory and run it via your browser? Delete it afterward, and see if it fixes your problems.
Thanks, Ryan Edit: Sorry, there was a bug in the file. ![]() My Blog - My Mods - My Site |
|||
|
09-08-2008, 11:37 PM
(This post was last modified: 09-08-2008 11:50 PM by Choli.)
Post: #5
|
|||
|
|||
RE: [F] IP search bug when ip >= 128.0.0.0
(09-08-2008 10:45 PM)Ryan Gordon Wrote: This'll be fixed in 1.4.1Better in 1.4.2 ![]() (09-08-2008 11:02 PM)Ryan Gordon Wrote: Can you put this file in your main directory and run it via your browser? Delete it afterward, and see if it fixes your problems.Ok. Let's see: (first of all, the file has a little typo: it's longregip instead of logrepip, in the first write_query; but that has not been a problem) So: the file executes correctly: Code: Performing necessary queries..IMHO, wouldn't it be easier to modify modcp.php in order to make que query using a positive number instead of modifying the DB? Something like this: PHP Code: $post_ip_sql = "longipaddress='" . sprintf("%u", $ip_range) . "'"; Edit: i've just quickly tested the sprintf workarround and it seems not to work ... it's too late at night here, maybe tomorrow i'll give it another try ![]() Edit2: In the DB I have the number 2147483647 in the longip columns for the rows with ip = 213.201.17.42; but that number is 0x7FFFFFFF (the maximun positive integer number in 2's complement using 32 bits) and that number is not the value returned by ip2long (or, at least, it should not be). And that happens before and after applying the patch. Maybe that can be a clue for you
|
|||
|
09-08-2008, 11:57 PM
Post: #6
|
|||
|
|||
|
RE: [F] IP search bug when ip >= 128.0.0.0
From memory, PHP's "int" datatype is just a signed 32 bit integer. In MySQL, the "int" type is also a 32 bit integer, signed by default.
Thus, from memory, PHP's ip2long() function returns a signed integer. Thus using positive numbers won't work. I haven't tested things, so I'm just putting what I know forward. |
|||
|
« Next Oldest | Next Newest »
|
Search
Member List
Calendar
Help



![[Image: ryangordon.png]](http://belloman.rctgo.net/stuff/signatures/ryangordon.png)


... it's too late at night here, maybe tomorrow i'll give it another try 
