This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=012ab5b83140547cbe73afec2b7dc511f56879c4

commit 012ab5b83140547cbe73afec2b7dc511f56879c4
Author: Guillem Jover <[email protected]>
AuthorDate: Thu May 21 06:09:54 2020 +0200

    libdpkg: Move version unterminated case in dependency parser before 
catch-all
    
    The code had a dead branch that would never trigger due to the previous
    catch-all one. Move it at the beginning.
    
    Warned-by: cppcheck (knownConditionTrueFalse)
    Fixes: commit 4f291d7421b7b991fcd61fce47591845725309ff
---
 debian/changelog  |  3 +++
 lib/dpkg/fields.c | 10 +++++-----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 73ffb59df..53db7133f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -18,6 +18,9 @@ dpkg (1.20.1) UNRELEASED; urgency=medium
     Reported by Niels Thykier <[email protected]>.
   * dpkg-split: Fix off-by-one check in ar header padding, that was making
     parsing error out on valid archives. Regression introduced in dpkg 1.18.8.
+  * libdpkg: Fix error message for ending version character in dependency
+    parser:
+    - Move the version unterminated case before the catchall.
   * Portability:
     - libdpkg: When using uselocale(), include <xlocale.h> for locale_t if
       the header is available. Needed on BSDs.
diff --git a/lib/dpkg/fields.c b/lib/dpkg/fields.c
index 8294149b9..5dacdd204 100644
--- a/lib/dpkg/fields.c
+++ b/lib/dpkg/fields.c
@@ -573,7 +573,11 @@ f_dependency(struct pkginfo *pkg, struct pkgbin *pkgbin,
        versionlength= p - versionstart;
         while (c_isspace(*p))
           p++;
-        if (*p == '(')
+        if (*p == '\0')
+          parse_error(ps,
+                      _("'%s' field, reference to '%.255s': "
+                        "version unterminated"), fip->name, depname.buf);
+        else if (*p == '(')
           parse_error(ps,
                       _("'%s' field, reference to '%.255s': "
                         "version contains '%c'"), fip->name, depname.buf, ')');
@@ -581,10 +585,6 @@ f_dependency(struct pkginfo *pkg, struct pkgbin *pkgbin,
           parse_error(ps,
                       _("'%s' field, reference to '%.255s': "
                         "version contains '%c'"), fip->name, depname.buf, ' ');
-        else if (*p == '\0')
-          parse_error(ps,
-                      _("'%s' field, reference to '%.255s': "
-                        "version unterminated"), fip->name, depname.buf);
         varbuf_reset(&version);
         varbuf_add_buf(&version, versionstart, versionlength);
         varbuf_end_str(&version);

-- 
Dpkg.Org's dpkg

Reply via email to