Merge ~ahasenack/ubuntu/+source/cacti:focal-cacti-32bit-dep8-failure into ubuntu/+source/cacti:ubuntu/devel

Proposed by Andreas Hasenack
Status: Merged
Approved by: Andreas Hasenack
Approved revision: 4b05e01490f95a587a95b1a3bf63fba16e42d6d7
Merged at revision: 4b05e01490f95a587a95b1a3bf63fba16e42d6d7
Proposed branch: ~ahasenack/ubuntu/+source/cacti:focal-cacti-32bit-dep8-failure
Merge into: ubuntu/+source/cacti:ubuntu/devel
Diff against target: 55 lines (+33/-0)
3 files modified
debian/changelog (+7/-0)
debian/patches/fix-32bit-ip-conversion.patch (+25/-0)
debian/patches/series (+1/-0)
Reviewer Review Type Date Requested Status
Christian Ehrhardt  (community) Approve
Canonical Server Pending
Review via email: mp+380111@code.launchpad.net

Description of the change

Bileto ticket: https://bileto.ubuntu.com/#/ticket/3960

Fix netmask calculation on armhf (32bits).

To test:

sudo apt install php-cli
php -a

Original code:
64bits:
php > $range = 24;
php > var_dump(bindec(str_repeat("1", $range) . str_repeat("0", 32-$range)));
int(4294967040) <--- it's an int!
php > var_dump(long2ip(4294967040));
string(13) "255.255.255.0"

32bits:
php > $range = 24;
php > var_dump(bindec(str_repeat("1", $range) . str_repeat("0", 32-$range)));
float(4294967040) <-- it's a float!
php > var_dump(long2ip(4294967040));
PHP Warning: long2ip() expects parameter 1 to be int, float given in php shell code on line 1
NULL

new code, 32bits:
php > $range = 24;
php > var_dump(long2ip((2**$range-1) << (32-$range)));
string(13) "255.255.255.0"

new code, 64bits:
php > $range = 24;
php > var_dump(long2ip((2**$range-1) << (32-$range)));
string(13) "255.255.255.0"
php >

Same results on armhf, amd64, ppc64el, s390x, arm64.

To post a comment you must log in.
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Changelog good
Patch good
Upstreaming good (ongoing still)
Fix works as expected

+1

review: Approve
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Thanks, tagging and uploading 4b05e01490f95a587a95b1a3bf63fba16e42d6d7

$ git push pkg upload/1.2.9+ds1-1ubuntu2
Enumerating objects: 16, done.
Counting objects: 100% (16/16), done.
Delta compression using up to 4 threads
Compressing objects: 100% (11/11), done.
Writing objects: 100% (11/11), 1.83 KiB | 170.00 KiB/s, done.
Total 11 (delta 7), reused 0 (delta 0)
To ssh://git.launchpad.net/~usd-import-team/ubuntu/+source/cacti
 * [new tag] upload/1.2.9+ds1-1ubuntu2 -> upload/1.2.9+ds1-1ubuntu2

$ dput ubuntu ../cacti_1.2.9+ds1-1ubuntu2_source.changes
Checking signature on .changes
gpg: ../cacti_1.2.9+ds1-1ubuntu2_source.changes: Valid signature from AC983EB5BF6BCBA9
Checking signature on .dsc
gpg: ../cacti_1.2.9+ds1-1ubuntu2.dsc: Valid signature from AC983EB5BF6BCBA9
Uploading to ubuntu (via ftp to upload.ubuntu.com):
  Uploading cacti_1.2.9+ds1-1ubuntu2.dsc: done.
  Uploading cacti_1.2.9+ds1-1ubuntu2.debian.tar.xz: done.
  Uploading cacti_1.2.9+ds1-1ubuntu2_source.buildinfo: done.
  Uploading cacti_1.2.9+ds1-1ubuntu2_source.changes: done.
Successfully uploaded packages.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 81e2743..31d67b5 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,10 @@
6+cacti (1.2.9+ds1-1ubuntu2) focal; urgency=medium
7+
8+ * d/p/fix-32bit-ip-conversion.patch: fix netmask generation on 32bit
9+ architectures (LP: #1865067)
10+
11+ -- Andreas Hasenack <andreas@canonical.com> Mon, 02 Mar 2020 14:52:15 -0300
12+
13 cacti (1.2.9+ds1-1ubuntu1) focal; urgency=medium
14
15 * Merge with Debian unstable (LP: #1863739). Remaining changes:
16diff --git a/debian/patches/fix-32bit-ip-conversion.patch b/debian/patches/fix-32bit-ip-conversion.patch
17new file mode 100644
18index 0000000..9262eee
19--- /dev/null
20+++ b/debian/patches/fix-32bit-ip-conversion.patch
21@@ -0,0 +1,25 @@
22+Description: Fix 32bit netmask generation
23+ bindec() may return a float instead of an int if needed, see
24+ https://www.php.net/manual/en/function.bindec.php. For IP netmasks, which is
25+ what it is being used for here, this happens almost always on 32bit
26+ architectures, in which case long2ip() will fail, as it only takes an int.
27+Author: Andreas Hasenack <andreas@canonical.com>
28+Bug: https://github.com/Cacti/cacti/issues/3310
29+Bug-Ubuntu: https://bugs.launchpad.net/cacti/+bug/1865067
30+Forwarded: https://github.com/Cacti/cacti/pull/3311
31+Last-Update: 2020-03-02
32+---
33+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
34+diff --git a/lib/api_automation.php b/lib/api_automation.php
35+index a1373af08..b9fffbeeb 100644
36+--- a/lib/api_automation.php
37++++ b/lib/api_automation.php
38+@@ -3003,7 +3003,7 @@ function automation_get_valid_mask($range) {
39+ $cidr = $range;
40+ $mask = array(
41+ 'cidr' => $cidr,
42+- 'subnet' => long2ip(bindec(str_repeat('1',$range) . str_repeat('0',32-$range))));
43++ 'subnet' => long2ip((2**$range-1) << (32-$range)));
44+ } else {
45+ $mask = false;
46+ }
47diff --git a/debian/patches/series b/debian/patches/series
48index 75b7da0..541367e 100644
49--- a/debian/patches/series
50+++ b/debian/patches/series
51@@ -3,3 +3,4 @@ enable-system-jqueryui-by-putting-cacti-changes-in-main.css.patch
52 perl-path.patch
53 font-awesome-path.patch
54 general-instructions-no-auto-create-user.patch
55+fix-32bit-ip-conversion.patch

Subscribers

People subscribed via source and target branches