reassign 626937 cupt 2.0.2
found 626937 cupt/2.1.1
tags 626937 = patch
quit

Hi Eugene and Francesco,

Francesco Poli wrote:

> I think you mean a line like
>
>  packagename - <  **CONFIGURE**
>
> which apt-listbugs would see as four fields instead of five.
> Anyway, it's possible that this is what happened, but, why?
> Did you manage to understand whether and *why* Cupt sent something
> wrong in the Version 2 APT hook protocol on your qemu-emulated system?

Well, the above guess was close.  At last I reproduced it again (and
was able to capture the output this time); fix follows.  Will attach
the output in a separate message for the curious.

Presumably the triggering condition is for the difference returned by
memcmp to be at least 2, which is why I was able to run into this on a
VM I hadn't upgraded for a while but not with everyday upgrades.

Thanks again for your help.

-- >8 --
In some cases compareVersionStrings passes on the return value from
memcmp, which is not guaranteed to be 1, -1, or 0. Most callers don't
mind, but one does: the value gets used in a switch statement to set
the comparison symbol for use in VERSION 2 apt pre-installation hook
output, and since no case label matches, the comparison symbol string
is left empty, resulting in hook output with lines like

        libgnutls26 2.12.5-1  2.12.7-1 **CONFIGURE**

where there should be

        libgnutls26 2.12.5-1 < 2.12.7-1 **CONFIGURE**

and apt-listbugs crashing with the message

        E: private method `chomp!' called for nil:NilClass

because it sees 4 fields where there should be 5. Fix it by only
checking the sign of the return value from compareVersionStrings
instead of switching on its value.

Signed-off-by: Jonathan Nieder <jrnie...@gmail.com>
---
 cpp/lib/src/internal/worker/packages.cpp |   14 ++++++++++----
 debian/changelog                         |    9 +++++++--
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/cpp/lib/src/internal/worker/packages.cpp 
b/cpp/lib/src/internal/worker/packages.cpp
index 730e7f5f..7b2351d2 100644
--- a/cpp/lib/src/internal/worker/packages.cpp
+++ b/cpp/lib/src/internal/worker/packages.cpp
@@ -1621,11 +1621,17 @@ string 
PackagesWorker::__generate_input_for_preinstall_v2_hooks(
                        else
                        {
                                auto comparisonResult = 
compareVersionStrings(oldVersionString, newVersionString);
-                               switch (comparisonResult)
+                               if (comparisonResult < 0)
                                {
-                                       case -1: compareVersionStringsSign = 
"<"; break;
-                                       case  0: compareVersionStringsSign = 
"="; break;
-                                       case  1: compareVersionStringsSign = 
">"; break;
+                                       compareVersionStringsSign = "<";
+                               }
+                               else if (comparisonResult == 0)
+                               {
+                                       compareVersionStringsSign = "=";
+                               }
+                               else
+                               {
+                                       compareVersionStringsSign = ">";
                                }
                        }
 
diff --git a/debian/changelog b/debian/changelog
index 6c438bc3..bb557eb1 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,8 +5,13 @@ cupt (2.1.2~) UNRELEASED; urgency=low
       used within the 'shell' subcommand. Thanks to Karol Kozłowski for the
       report.
   * lib:
-    - Fixed a double use of va_list. Thanks to Julian Andres Klode for the
-      report and the patch. (Closes: #630824)
+    - common:
+      - Fixed a double use of va_list. Thanks to Julian Andres Klode for the
+        report and the patch. (Closes: #630824)
+    - system/worker:
+      - [Jonathan Nieder] Do not assume the return value from memcmp is -1, 0,
+        or 1. Fixes a bug in which cupt would sometimes leave out the <, =,
+        or > symbol in VERSION 2 input for preinstall hooks. (Closes: #626937)
 
  -- Eugene V. Lyubimkin <jac...@debian.org>  Mon, 20 Jun 2011 19:07:35 +0300
 
-- 
1.7.6




--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to