Преглед изворни кода

dpkg-query: Do not allow more than two arguments for --control-path

The last increment to argv was not being used, but instead the
increment, make it useful by checking if there's any additional
argument after the second, and bail out in that case.

This was spotted by a run with the clang static analyzer.
Guillem Jover пре 17 година
родитељ
комит
4a6590edfb
1 измењених фајлова са 4 додато и 2 уклоњено
  1. 4 2
      src/query.c

+ 4 - 2
src/query.c

@@ -525,12 +525,14 @@ control_path(const char *const *argv)
   const char *control_file;
 
   pkg_name = *argv++;
-  control_file = *argv++;
-
   if (!pkg_name)
     badusage(_("--%s needs at least one package name argument"),
              cipaction->olong);
 
+  control_file = *argv++;
+  if (control_file && *argv)
+    badusage(_("--%s takes at most two arguments"), cipaction->olong);
+
   /* Validate control file name for sanity. */
   if (control_file) {
     const char *c;