Parcourir la source

u-a: Fix segfault when using --slave without any action

The case of --slave with a non-install action was already handled, but
not the case of missing action.

LP: #1037431
Guillem Jover il y a 13 ans
Parent
commit
105e556ea0
2 fichiers modifiés avec 4 ajouts et 1 suppressions
  1. 2 0
      debian/changelog
  2. 2 1
      utils/update-alternatives.c

+ 2 - 0
debian/changelog

@@ -17,6 +17,8 @@ dpkg (1.16.9) UNRELEASED; urgency=low
   * Fix update-alternatives test suite to behave correctly on non-Debian
     binary paths. Known to be affecting at least Gentoo and Mac OS X.
   * Do not leak subcall command arguments in update-alternatives.
+  * Fix segfault on update-alternatives when passing --slave without any
+    action at all. LP: #1037431
 
   [ Updated programs translations ]
   * Czech (Miroslav Kure).

+ 2 - 1
utils/update-alternatives.c

@@ -2533,7 +2533,8 @@ main(int argc, char **argv)
 			char *slink, *sname, *spath;
 			struct slave_link *sl;
 
-			if (action && strcmp(action, "install") != 0)
+			if (action == NULL ||
+			    (action && strcmp(action, "install") != 0))
 				badusage(_("--slave only allowed with --install"));
 			if (MISSING_ARGS(3))
 				badusage(_("--slave needs <link> <name> <path>"));