Bläddra i källkod

dpkg-maintscript-helper: handle missing parameters properly

Raphaël Hertzog 16 år sedan
förälder
incheckning
a0b267ec59
2 ändrade filer med 12 tillägg och 2 borttagningar
  1. 2 0
      debian/changelog
  2. 10 2
      scripts/dpkg-maintscript-helper.sh

+ 2 - 0
debian/changelog

@@ -19,6 +19,8 @@ dpkg (1.15.8) UNRELEASED; urgency=low
     Closes: #582401
   * Modify Dpkg::Shlibs::Objdump to use the cross objdump binary when cross
     compiling. Thanks to Loïc Minier for the initial patch. Closes: #578365
+  * Make dpkg-maintscript-helper more robust when required parameters are
+    missing. Closes: #582814
 
   [ Guillem Jover ]
   * Require gettext 0.18:

+ 10 - 2
scripts/dpkg-maintscript-helper.sh

@@ -34,7 +34,8 @@ rm_conffile() {
 		PACKAGE="$DPKG_MAINTSCRIPT_PACKAGE"
 	fi
 	# Skip remaining parameters up to --
-	while [ "$1" != "--" -a "$1" != "" ]; do shift; done
+	while [ "$1" != "--" -a $# -gt 0 ]; do shift; done
+	[ $# -gt 0 ] || badusage
 	shift
 
 	[ -n "$PACKAGE" ] || error "couldn't identify the package"
@@ -127,7 +128,8 @@ mv_conffile() {
 		PACKAGE="$DPKG_MAINTSCRIPT_PACKAGE"
 	fi
 	# Skip remaining parameters up to --
-	while [ "$1" != "--" -a "$1" != "" ]; do shift; done
+	while [ "$1" != "--" -a $# -gt 0 ]; do shift; done
+	[ $# -gt 0 ] || badusage
 	shift
 
 	[ -n "$PACKAGE" ] || error "couldn't identify the package"
@@ -239,12 +241,18 @@ Commands and parameters:
 END
 }
 
+badusage() {
+	usage
+	exit 1
+}
+
 # Main code
 set -e
 
 PROGNAME=$(basename $0)
 version="unknown"
 command="$1"
+[ $# -gt 0 ] || badusage
 shift
 
 case "$command" in