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

dpkg: refuses empty parameters when integer expected

Fix setinteger() funtion used for parsing integer options to
refuse empty parameters. Currently only affects --abort-after.

Based-on-patch-by: Bill Allombert <ballombe@debian.org>
Raphael Hertzog пре 17 година
родитељ
комит
d80d6958a2
3 измењених фајлова са 4 додато и 1 уклоњено
  1. 1 0
      THANKS
  2. 2 0
      debian/changelog
  3. 1 1
      src/main.c

+ 1 - 0
THANKS

@@ -17,6 +17,7 @@ Bart Martens <bart.martens@advalvas.be>
 Bastian Kleineidam <calvin@debian.org>
 Bastian Kleineidam <calvin@debian.org>
 Ben Collins <bcollins@debian.org>
 Ben Collins <bcollins@debian.org>
 Ben Pfaff <blp@cs.stanford.edu>
 Ben Pfaff <blp@cs.stanford.edu>
+Bill Allombert <ballombe@debian.org>
 Branden Robinson <branden@debian.org>
 Branden Robinson <branden@debian.org>
 Branko Lankester
 Branko Lankester
 Brian M. Carlson <sandals@crustytoothpaste.ath.cx>
 Brian M. Carlson <sandals@crustytoothpaste.ath.cx>

+ 2 - 0
debian/changelog

@@ -43,6 +43,8 @@ dpkg (1.15.1) UNRELEASED; urgency=low
     arguments starting with a dash are not interpreted as options.
     arguments starting with a dash are not interpreted as options.
     Closes: #293163
     Closes: #293163
     Thanks to Bill Allombert for the patch.
     Thanks to Bill Allombert for the patch.
+  * dpkg now correctly refuses empty parameters when an integer value is
+    wanted. Closes: #386197 Based on a patch by Bill Allombert.
 
 
   [ Guillem Jover ]
   [ Guillem Jover ]
   * Fix typo in dpkg output (‘unexecpted’ → ‘unexpected’). Closes: #519082
   * Fix typo in dpkg output (‘unexecpted’ → ‘unexpected’). Closes: #519082

+ 1 - 1
src/main.c

@@ -293,7 +293,7 @@ static void setinteger(const struct cmdinfo *cip, const char *value) {
   char *ep;
   char *ep;
 
 
   v= strtoul(value,&ep,0);
   v= strtoul(value,&ep,0);
-  if (*ep || v > INT_MAX)
+  if (!*value || *ep || v > INT_MAX)
     badusage(_("invalid integer for --%s: `%.250s'"),cip->olong,value);
     badusage(_("invalid integer for --%s: `%.250s'"),cip->olong,value);
   *cip->iassignto= v;
   *cip->iassignto= v;
 }
 }