Package: release.debian.org
Severity: normal
Tags: bullseye
User: release.debian....@packages.debian.org
Usertags: pu
X-Debbugs-Cc: r...@ringlet.net

Hi,

First of all, thanks for all your work on Debian!

[ Reason ]
This is a future unblock request before I upload prips-1.1.1-3+deb11u1
to fix two upstream bugs that affect the base functionality of the program:
an infinite loop if it is asked to print the addresses in a block that
ends at the last IPv4 address (255.255.255.255), and incorrect output if
asked to combine two very different IP addresses (e.g. 1.1.1.1 and
230.120.1.1) into a single CIDR block.

[ Impact ]
Incorrect operation of the prips tool with certain input data.

[ Tests ]
The fix for the 255.255.255.255 address handling includes a test added
to the appropriate file in the test suite. The fix for the CIDR output
mode includes a new file in the test suite that tests CIDR output;
it was not possible to only include the single new test, since this file
did not exist in the prips-1.1.1 test suite in bullseye.

[ Risks ]
The fixes are almost trivial, given familiarity with the C language.

[ Checklist ]
  [x] *all* changes are documented in the d/changelog
  [x] I reviewed all changes and I approve them
  [x] attach debdiff against the package in stable
  [x] the issue is verified as fixed in unstable

[ Changes ]
- add a test for a block that ends at 255.255.255.255
- fix the operation of prips for such a block
- add a couple of tests for the CIDR mode output
- fix the prips CIDR output for certain input data

[ Other info ]

Thanks in advance, and keep up the great work!
diff -Nru prips-1.1.1/debian/changelog prips-1.1.1/debian/changelog
--- prips-1.1.1/debian/changelog        2020-05-10 18:58:46.000000000 +0300
+++ prips-1.1.1/debian/changelog        2021-12-26 23:15:45.000000000 +0200
@@ -1,3 +1,13 @@
+prips (1.1.1-3+deb11u1) bullseye; urgency=medium
+
+  * Add two patches from the 1.2.0 upstream version:
+    - stop-at-last-address: stop at 255.255.255.255 instead of wrapping
+      over to 0.0.0.0 and going on forever. Closes: #1001923
+    - fix-different-cidr: fix the CIDR (-c) output when the addresses
+      differ in their very first bit. Closes: #1001924
+
+ -- Peter Pentchev <r...@debian.org>  Sun, 26 Dec 2021 23:15:45 +0200
+
 prips (1.1.1-3) unstable; urgency=medium
 
   * Declare compliance with Debian Policy 4.5.0 with no changes.
diff -Nru prips-1.1.1/debian/patches/fix-different-cidr.patch 
prips-1.1.1/debian/patches/fix-different-cidr.patch
--- prips-1.1.1/debian/patches/fix-different-cidr.patch 1970-01-01 
02:00:00.000000000 +0200
+++ prips-1.1.1/debian/patches/fix-different-cidr.patch 2021-12-26 
23:15:45.000000000 +0200
@@ -0,0 +1,106 @@
+Description: CIDR mode: handle "totally different" correctly.
+ If the addresses differ in their very first bit, report "0.0.0.0/0"
+ instead of the incorrect "x.y.z.t/32".
+Bug-Debian: https://bugs.debian.org/1001924
+Origin: upstream, 
https://gitlab.com/prips/prips/-/commit/1afd3e6976f946317f3ac9980685549b5216a6f5
+Author: Peter Pentchev <r...@ringlet.net>
+Last-Updated: 2021-12-26
+
+--- /dev/null
++++ b/t/06-cidrize.t
+@@ -0,0 +1,74 @@
++#!/bin/sh
++#
++# Copyright (c) 2021  Peter Pentchev
++# All rights reserved.
++#
++# Redistribution and use in source and binary forms, with or without
++# modification, are permitted provided that the following conditions
++# are met:
++# 1. Redistributions of source code must retain the above copyright
++#    notice, this list of conditions and the following disclaimer.
++# 2. Redistributions in binary form must reproduce the above copyright
++#    notice, this list of conditions and the following disclaimer in the
++#    documentation and/or other materials provided with the distribution.
++#
++# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
++# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
++# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
++# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
++# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
++# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
++# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
++# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
++# SUCH DAMAGE.
++
++if [ -f 'tap-functions.sh' ]; then
++      . tap-functions.sh
++elif [ -f 't/tap-functions.sh' ]; then
++      . t/tap-functions.sh
++else
++      echo 'Bail out! Could not find tap-functions.sh'
++      exit 99
++fi
++
++[ -z "$PRIPS" ] && PRIPS='./prips'
++
++plan_ 12
++
++v=`$PRIPS -c 127.0.0.0 127.0.0.7 2>/dev/null`
++res="$?"
++exp='127.0.0.0/29'
++if [ "$res" = 0 ]; then ok_; else not_ok_ "exit code $res"; fi
++if [ "$v" = "$exp" ]; then ok_; else not_ok_ "expected $exp got $v"; fi
++
++v=`$PRIPS -c 127.0.0.2 127.0.0.6 2>/dev/null`
++res="$?"
++exp='127.0.0.0/29'
++if [ "$res" = 0 ]; then ok_; else not_ok_ "exit code $res"; fi
++if [ "$v" = "$exp" ]; then ok_; else not_ok_ "expected $exp got $v"; fi
++
++v=`$PRIPS -c 127.0.0.0 127.0.0.9 2>/dev/null`
++res="$?"
++exp='127.0.0.0/28'
++if [ "$res" = 0 ]; then ok_; else not_ok_ "exit code $res"; fi
++if [ "$v" = "$exp" ]; then ok_; else not_ok_ "expected $exp got $v"; fi
++
++v=`$PRIPS -c 192.168.17.42 192.168.18.3 2>/dev/null`
++res="$?"
++exp='192.168.16.0/22'
++if [ "$res" = 0 ]; then ok_; else not_ok_ "exit code $res"; fi
++if [ "$v" = "$exp" ]; then ok_; else not_ok_ "expected $exp got $v"; fi
++
++v=`$PRIPS -c 10.21.33.4 10.21.33.4 2>/dev/null`
++res="$?"
++exp='10.21.33.4/32'
++if [ "$res" = 0 ]; then ok_; else not_ok_ "exit code $res"; fi
++if [ "$v" = "$exp" ]; then ok_; else not_ok_ "expected $exp got $v"; fi
++
++v=`$PRIPS -c 10.21.33.4 210.21.33.4 2>/dev/null`
++res="$?"
++exp='0.0.0.0/0'
++if [ "$res" = 0 ]; then ok_; else not_ok_ "exit code $res"; fi
++if [ "$v" = "$exp" ]; then ok_; else not_ok_ "expected $exp got $v"; fi
+--- a/prips.c
++++ b/prips.c
+@@ -68,7 +68,7 @@
+ /**********************************************/
+ const char *cidrize(const uint32_t start, const uint32_t end)
+ {
+-      int offset = 0;
++      int offset = 32;
+ 
+       /* find the mask (offset) by finding the 
+        * highest bit set differently in the start
+@@ -87,6 +87,9 @@
+               diff = diff >> 1;
+       }
+ 
++      if (offset == 32)
++              return "0.0.0.0/0";
++
+       /* clear out the bits below the mask */
+       const uint32_t base = (start >> offset) << offset;
+ 
diff -Nru prips-1.1.1/debian/patches/series prips-1.1.1/debian/patches/series
--- prips-1.1.1/debian/patches/series   1970-01-01 02:00:00.000000000 +0200
+++ prips-1.1.1/debian/patches/series   2021-12-26 23:15:45.000000000 +0200
@@ -0,0 +1,2 @@
+stop-at-last-address.patch
+fix-different-cidr.patch
diff -Nru prips-1.1.1/debian/patches/stop-at-last-address.patch 
prips-1.1.1/debian/patches/stop-at-last-address.patch
--- prips-1.1.1/debian/patches/stop-at-last-address.patch       1970-01-01 
02:00:00.000000000 +0200
+++ prips-1.1.1/debian/patches/stop-at-last-address.patch       2021-12-26 
23:15:45.000000000 +0200
@@ -0,0 +1,46 @@
+Description: Fix stopping at 255.255.255.255.
+Bug-Debian: https://bugs.debian.org/1001923
+Origin: upstream, 
https://gitlab.com/prips/prips/-/commit/172f71f6803ba5b1212e8ffecccb013ee4adf40b
+Author: Peter Pentchev <r...@ringlet.net>
+Last-Updated: 2021-12-26
+
+--- a/main.c
++++ b/main.c
+@@ -172,7 +172,7 @@
+               printf("%s%c", cidrize(start, end), delimiter);
+       else
+       {
+-              for(uint32_t current = start; current <= end; current += 
increment) 
++              for(uint32_t current = start; current <= end && current >= 
start; current += increment) 
+               {       if(!exception_flag || !except(&current, octet, 
increment))
+                       {
+                               switch(format)
+--- a/t/02-range.t
++++ b/t/02-range.t
+@@ -1,6 +1,6 @@
+ #!/bin/sh
+ #
+-# Copyright (c) 2016  Peter Pentchev
++# Copyright (c) 2016, 2021  Peter Pentchev
+ # All rights reserved.
+ #
+ # Redistribution and use in source and binary forms, with or without
+@@ -35,7 +35,7 @@
+ 
+ [ -z "$PRIPS" ] && PRIPS='./prips'
+ 
+-plan_ 7
++plan_ 9
+ 
+ echo '# prips with no arguments should exit with code 1'
+ $PRIPS > /dev/null 2>&1
+@@ -58,3 +58,9 @@
+ res="$?"
+ if [ "$res" = 1 ]; then ok_; else not_ok_ "exit code $res"; fi
+ if [ -z "$v" ]; then ok_; else not_ok_ "expected $exp got $v"; fi
++
++v=`$PRIPS -d33 255.255.255.252/30 2>/dev/null`
++res="$?"
++exp='255.255.255.252!255.255.255.253!255.255.255.254!255.255.255.255!'
++if [ "$res" = 0 ]; then ok_; else not_ok_ "exit code $res"; fi
++if [ "$v" = "$exp" ]; then ok_; else not_ok_ "expected $exp got $v"; fi

Attachment: signature.asc
Description: PGP signature

Reply via email to