Public bug reported:

When using the IPv4Network.Supernet() call, the resulting address is
calculated incorrectly. Instead of presenting the all-zeros address in
the host part, the first bit of the host part is kept as it was, causing
an incorrect address to be displayed. This only appears to be a display
issue, the network objects behave as they should (at least for the
equality operator).

The following python program can be used to see the issue.

from sys import argv
import ipaddr

ip1 = ipaddr.IPv4Network(argv[1])
ip2 = ipaddr.IPv4Network(argv[2])


print "Testing ", str(ip1), str(ip2)
while ip1 != ip2:
        print ip1,ip2
        ip1 = ip1.Supernet()
        ip2 = ip2.Supernet()

print "Ending ", ip2

This program takes two addresses and attempts to find the network in
common, using the Supernet call to locate it. However, below is the
output of the program.

$ python ipaddr-bug-test.py 10.53.45.24 10.53.45.255
Testing  10.53.45.24/32 10.53.45.255/32
10.53.45.24/32 10.53.45.255/32
10.53.45.24/31 10.53.45.255/31
10.53.45.24/30 10.53.45.254/30
10.53.45.24/29 10.53.45.252/29
10.53.45.24/28 10.53.45.248/28
10.53.45.16/27 10.53.45.240/27
10.53.45.0/26 10.53.45.224/26
10.53.45.0/25 10.53.45.192/25
Ending  10.53.45.128/24

Note how the program correctly shows the /32 addresses, but when getting
the supernet for the second address, it mistakenly shows 10.53.45.255/31
when the correct value should have been 10.53.45.254/31. The same
happens in all the stages, and is very obvious when doing the
computation on a broadcast address. Finally, the address is constructed
with the wrong network address.

As for system data, here goes all the data indicated in the submission
instructions:

$ lsb_release -rd
Description:    Ubuntu 14.04.4 LTS
Release:        14.04

$ apt-cache policy python-ipaddr
python-ipaddr:
  Installed: 2.1.10-1
  Candidate: 2.1.10-1
  Version table:
 *** 2.1.10-1 0
        500 http://ar.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages
        100 /var/lib/dpkg/status

ProblemType: Bug
DistroRelease: Ubuntu 14.04
Package: python-ipaddr 2.1.10-1
ProcVersionSignature: Ubuntu 3.19.0-51.58~14.04.1-generic 3.19.8-ckt13
Uname: Linux 3.19.0-51-generic x86_64
ApportVersion: 2.14.1-0ubuntu3.19
Architecture: amd64
CurrentDesktop: XFCE
Date: Wed Mar 30 17:17:20 2016
EcryptfsInUse: Yes
InstallationDate: Installed on 2016-02-29 (29 days ago)
InstallationMedia: Xubuntu 14.04.3 LTS "Trusty Tahr" - Beta amd64 (20150805)
PackageArchitecture: all
SourcePackage: python-ipaddr
UpgradeStatus: No upgrade log present (probably fresh install)

** Affects: python-ipaddr (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: amd64 apport-bug trusty

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1564077

Title:
  ipaddr.IPv4Network object miscalculates network addresses

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/python-ipaddr/+bug/1564077/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to