소스 검색

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 년 전
부모
커밋
5ddae0e364
2개의 변경된 파일11개의 추가작업 그리고 1개의 파일을 삭제
  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
     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
     version means that the symbol has always existed in all versions of the
     package.
     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 ]
   [ Guillem Jover ]
   * Fix typo in dpkg output (‘unexecpted’ → ‘unexpected’). Closes: #519082
   * 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;
     pass_admindir = 1;
   }
   }
 
 
-  nargv = m_malloc(sizeof(char *) * (argc + 2));
+  nargv = m_malloc(sizeof(char *) * (argc + 3));
   nargv[i] = m_strdup(cipaction->parg);
   nargv[i] = m_strdup(cipaction->parg);
 
 
   i++, offset++;
   i++, offset++;
@@ -515,6 +515,11 @@ void execbackend(const char *const *argv) {
   strcat(nargv[i], cipaction->olong);
   strcat(nargv[i], cipaction->olong);
   i++, offset++;
   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. */
   /* Copy arguments from argv to nargv. */
   for (; i <= argc; i++)
   for (; i <= argc; i++)
     nargv[i] = m_strdup(argv[i - offset]);
     nargv[i] = m_strdup(argv[i - offset]);