64-bit qBittorrent crashes when using P2P filter list
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
qBittorrent |
Fix Released
|
Undecided
|
Christophe Dumez | ||
qbittorrent (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
This is regarding qBittorrent on a vanilla 64-bit Ubuntu Jaunty install with Boost v1.37.0-3ubuntu3. The bug is in both the 1.3.3 version (Jaunty) and also the 1.4.0 beta2. I believe this only affects 64-bit builds.
If you have a Peerguardian style filter entry with the first octet 128 or higher then qBittorrent with crash with:
terminate called after throwing an instance of 'boost:
what(): address_v4 from unsigned long
The problem is in parseP2PFilterF
address_v4 start((
The issue is that Boost address_v4 uses an unsigned long integer which is 64-bits. When the first octet is 128 or higher the that signed left shift will create a negative long integer which then will result in an invalid 64-bit unsigned long IP address.
One solution is to use the unsigned "toUInt()" instead of the signed version when creating address for address_v4. Another would be to cast the whole constructed IP number to a 32-bit unsigned long.
There may be more areas in the code with this same problem. Anywhere the address_v4 object is used on 64-bit builds.
To reproduce just create a p2p filter file with one entry:
Test Range:128.
Thanks a lot for the report and the fix. I have just committed the fix to SVN (Chose to use toUInt() instead of toInt()).