Commit 0ede9455 authored by Guillem Jover's avatar Guillem Jover

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

Conflicts:
	debian/changelog
parents fddd49ee 34b3f86b
......@@ -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
......
......@@ -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 */
......@@ -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);
}
......@@ -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]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment