Prechádzať zdrojové kódy

dpkg: separate arguments with "--" when calling dpkg-{deb,query}

This is needed because any user-supplied argument separator is stripped by
the option parser such as "dpkg -S -- -pic" ends up calling "dpkg-query
--search -pic" which fails. With this patch, it calls "dpkg-query --search
-- -pic" and works as expected.
Bill Allombert 17 rokov pred
rodič
commit
5ddae0e364
2 zmenil súbory, kde vykonal 11 pridanie a 1 odobranie
  1. 5 0
      debian/changelog
  2. 6 1
      src/main.c

+ 5 - 0
debian/changelog

@@ -38,6 +38,11 @@ dpkg (1.15.1) UNRELEASED; urgency=low
     even when some symbols are associated with a (fake) version "0". Such a
     version means that the symbol has always existed in all versions of the
     package.
+  * When dpkg delegates to dpkg-query or dpkg-deb to do the actual work, add
+    the "--" marker to explicitely document the end of options so that
+    arguments starting with a dash are not interpreted as options.
+    Closes: #293163
+    Thanks to Bill Allombert for the patch.
 
   [ Guillem Jover ]
   * Fix typo in dpkg output (‘unexecpted’ → ‘unexpected’). Closes: #519082

+ 6 - 1
src/main.c

@@ -499,7 +499,7 @@ void execbackend(const char *const *argv) {
     pass_admindir = 1;
   }
 
-  nargv = m_malloc(sizeof(char *) * (argc + 2));
+  nargv = m_malloc(sizeof(char *) * (argc + 3));
   nargv[i] = m_strdup(cipaction->parg);
 
   i++, offset++;
@@ -515,6 +515,11 @@ void execbackend(const char *const *argv) {
   strcat(nargv[i], cipaction->olong);
   i++, offset++;
 
+  /* Exlicitely separate arguments from options as any user-supplied
+   * separator got stripped by the option parser */
+  nargv[i] = "--";
+  i++, argc++, offset++;
+
   /* Copy arguments from argv to nargv. */
   for (; i <= argc; i++)
     nargv[i] = m_strdup(argv[i - offset]);