The following commit has been merged in the master branch:
commit af9e264518c4cab8e70788d0724d362ef25534d6
Author: Guillem Jover <[EMAIL PROTECTED]>
Date:   Sun Jun 1 20:09:16 2008 +0300

    dpkg-query: Trim trailing slash and slash dot from arguments
    
    Do this when the arguments are path names, but not on patterns, to avoid
    unexpected behaviour. Closes: #129577

diff --git a/ChangeLog b/ChangeLog
index 8424c71..46b3549 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2008-06-01  Guillem Jover  <[EMAIL PROTECTED]>
 
+       * src/query.c: Include <dpkg-priv.h>.
+       (searchfiles): Trim trailing '/' and '/.' from file searches only
+       on path names, but not patterns.
+
+2008-06-01  Guillem Jover  <[EMAIL PROTECTED]>
+
        * lib/dpkg-priv.h (rtrim_slash_slashdot): Return the string size.
 
 2008-06-01  Raphael Hertzog  <[EMAIL PROTECTED]>
diff --git a/debian/changelog b/debian/changelog
index d4d43b7..041413f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -10,6 +10,8 @@ dpkg (1.15.0) UNRELEASED; urgency=low
   * Fix link order when using libcompat.a and libintl.a by placing them after
     libdpkg.a. Based on a patch by Martin Koeppe. Closes: #481805
   * Remove duplicate program name from dpkg-trigger badusage output.
+  * Trim trailing slash and slash dot from 'dpkg -S' arguments when those
+    are path names, but not on patterns. Closes: #129577
 
   [ Raphael Hertzog ]
   * Enhance dpkg-shlibdeps's error message when a library can't be found to
diff --git a/src/query.c b/src/query.c
index dd6d25a..237945d 100644
--- a/src/query.c
+++ b/src/query.c
@@ -38,6 +38,7 @@
 
 #include <dpkg.h>
 #include <dpkg-db.h>
+#include <dpkg-priv.h>
 #include <myopt.h>
 
 #include "filesdb.h"
@@ -244,17 +245,33 @@ void searchfiles(const char *const *argv) {
   struct fileiterator *it;
   const char *thisarg;
   int found;
+  struct varbuf path;
   static struct varbuf vb;
   
   if (!*argv)
     badusage(_("--search needs at least one file name pattern argument"));
 
+  varbufinit(&path);
+
   modstatdb_init(admindir,msdbrw_readonly|msdbrw_noavail);
   ensure_allinstfiles_available_quiet();
   ensure_diversions();
 
   while ((thisarg= *argv++) != 0) {
     found= 0;
+
+    /* Trim trailing slash and slash dot from the argument if it's
+     * not a pattern, just a path.
+     */
+    if (!strpbrk(thisarg, "*[?\\")) {
+      varbufreset(&path);
+      varbufaddstr(&path, thisarg);
+      varbufaddc(&path, '\0');
+
+      path.used = rtrim_slash_slashdot(path.buf);
+      thisarg = path.buf;
+    }
+
     if (!strchr("*[?/",*thisarg)) {
       varbufreset(&vb);
       varbufaddc(&vb,'*');
@@ -283,6 +300,8 @@ void searchfiles(const char *const *argv) {
     }
   }
   modstatdb_shutdown();
+
+  varbuffree(&path);
 }
 
 void enqperpackage(const char *const *argv) {

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to