64-bit qBittorrent crashes when using P2P filter list

Bug #371283 reported by Eric Porter
6
This bug affects 1 person
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::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::out_of_range> >'
  what(): address_v4 from unsigned long

The problem is in parseP2PFilterFile(). When it creates the start and last address_v4 objects it uses:
address_v4 start((IP.at(0).toInt() << 24) ...

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.1.0.0-128.1.255.255

Revision history for this message
Christophe Dumez (hydr0g3n) wrote :

Thanks a lot for the report and the fix. I have just committed the fix to SVN (Chose to use toUInt() instead of toInt()).

Changed in qbittorrent:
assignee: nobody → Christophe Dumez (hydr0g3n)
milestone: none → 1.3.4
status: New → Fix Committed
Revision history for this message
Christophe Dumez (hydr0g3n) wrote :

Here is the patch. Would it be possible to apply it to the Ubuntu package please?

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package qbittorrent - 1.3.3-2

---------------
qbittorrent (1.3.3-2) unstable; urgency=low

  * debian/control: add Vcs-* addresses (switch to git-buildpackage).
  * debian/{control,rules}:
    - build depends on debhelper (>= 7.0.50) and use the new
      override_dh_command feature;
    - build-depends on quilt patch system
      + debian/patches/fix_ipfilter_amd64.patch: pulled from upstream
        svn r2344 (LP: #371283).
  * debian/{clean,qbittorrent.install}: added files to simplify debian/rules.

 -- Ubuntu Archive Auto-Sync <email address hidden> Mon, 01 Jun 2009 10:45:45 +0100

Changed in qbittorrent (Ubuntu):
status: New → Fix Released
Revision history for this message
Christophe Dumez (hydr0g3n) wrote :

v1.3.4 was released.

Changed in qbittorrent:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.