ソースを参照

Merge branch 'sid' (through tag '1.16.4.3')

Conflicts:
	debian/changelog
Guillem Jover 14 年 前
コミット
0ede945564
共有4 個のファイルを変更した37 個の追加3 個の削除を含む
  1. 11 0
      debian/changelog
  2. 13 0
      lib/dpkg/macros.h
  3. 6 1
      lib/dpkg/test/t-macros.c
  4. 7 2
      utils/update-alternatives.c

+ 11 - 0
debian/changelog

@@ -20,6 +20,17 @@ dpkg (1.16.5) UNRELEASED; urgency=low
 
  -- Guillem Jover <guillem@debian.org>  Fri, 08 Jun 2012 09:39:42 +0200
 
+dpkg (1.16.4.3) unstable; urgency=low
+
+  * On «update-alternatives --install» only warn for now on out of range
+    priorities and clamp the values, as there seems to be packages using
+    priorities > INT_MAX, which although bogus as they were previously
+    overflowing the int used to store them, that would cause installation
+    failures when upgrading from squeeze. This will be reverted to an
+    error after wheezy. Closes: #676874
+
+ -- Guillem Jover <guillem@debian.org>  Sun, 17 Jun 2012 10:56:15 +0200
+
 dpkg (1.16.4.2) unstable; urgency=low
 
   * Check correctly for out of range negative field width values in dpkg-query

+ 13 - 0
lib/dpkg/macros.h

@@ -115,6 +115,19 @@
 #endif
 #endif
 
+/**
+ * @def clamp
+ *
+ * Returns a normalized value within the low and high limits.
+ *
+ * @param v The value to clamp.
+ * @param l The low limit.
+ * @param h The high limit.
+ */
+#ifndef clamp
+#define clamp(v, l, h) ((v) > (h) ? (h) : ((v) < (l) ? (l) : (v)))
+#endif
+
 /** @} */
 
 #endif /* LIBDPKG_MACROS_H */

+ 6 - 1
lib/dpkg/test/t-macros.c

@@ -2,7 +2,7 @@
  * libdpkg - Debian packaging suite library routines
  * t-macros.c - test C support macros
  *
- * Copyright © 2009 Guillem Jover <guillem@debian.org>
+ * Copyright © 2009,2012 Guillem Jover <guillem@debian.org>
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -36,4 +36,9 @@ test(void)
 	test_pass(max(30, 10) == 30);
 	test_pass(max(0, 10) == 10);
 	test_pass(max(-10, 0) == 0);
+
+	test_pass(clamp(0, 0, 0) == 0);
+	test_pass(clamp(0, -10, 10) == 0);
+	test_pass(clamp(20, -10, 10) == 10);
+	test_pass(clamp(-20, -10, 10) == -10);
 }

+ 7 - 2
utils/update-alternatives.c

@@ -2476,8 +2476,13 @@ main(int argc, char **argv)
 			prio = strtol(prio_str, &prio_end, 10);
 			if (prio_str == prio_end || *prio_end != '\0')
 				badusage(_("priority must be an integer"));
-			if (prio < INT_MIN || prio > INT_MAX || errno == ERANGE)
-				badusage(_("priority is out of range"));
+			if (prio < INT_MIN || prio > INT_MAX || errno == ERANGE) {
+				/* XXX: Switch back to error on 1.17.x. */
+				prio = clamp(prio, INT_MIN, INT_MAX);
+				warning(_("priority is out of range: "
+				          "%s clamped to %ld"),
+				        prio_str, prio);
+			}
 
 			a = alternative_new(argv[i + 2]);
 			inst_alt = alternative_new(argv[i + 2]);