From: Nicolas François Date: Mon, 12 Aug 2013 22:11:24 +0000 (+0200) Subject: Fix handling of boundaries. X-Git-Tag: 4.2.1~34 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bfbd83239e55dd8e8ba351cb4fa18359c85cc996;p=thirdparty%2Fshadow.git Fix handling of boundaries. * lib/subordinateio.c: Fix handling of boundaries. * libmisc/find_new_sub_uids.c: Likewise. * libmisc/find_new_sub_gids.c: Likewise. --- diff --git a/ChangeLog b/ChangeLog index 42483eb77..c2ef35f9f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2013-08-13 Nicolas François + + * lib/subordinateio.c: Fix handling of boundaries. + * libmisc/find_new_sub_uids.c: Likewise. + * libmisc/find_new_sub_gids.c: Likewise. + 2013-08-12 Nicolas François * lib/subordinateio.c: Fix removal of ranges. The database needs diff --git a/lib/subordinateio.c b/lib/subordinateio.c index 34630f2c6..4e94104c0 100644 --- a/lib/subordinateio.c +++ b/lib/subordinateio.c @@ -228,7 +228,7 @@ static unsigned long find_free_range(struct commonio_db *db, unsigned long low, high; /* When given invalid parameters fail */ - if ((count == 0) || (max <= min)) + if ((count == 0) || (max < min)) goto fail; /* Sort by range then by owner */ @@ -246,7 +246,7 @@ static unsigned long find_free_range(struct commonio_db *db, high = max; /* Is the hole before this range large enough? */ - if ((high > low) && (((high - low) + 1) >= count)) + if ((high > low) && ((high - low) >= count)) return low; /* Compute the low end of the next hole */ diff --git a/libmisc/find_new_sub_gids.c b/libmisc/find_new_sub_gids.c index 1b008fbe9..5d12d9ac2 100644 --- a/libmisc/find_new_sub_gids.c +++ b/libmisc/find_new_sub_gids.c @@ -60,7 +60,7 @@ int find_new_sub_gids (const char *owner, max = getdef_ulong ("SUB_GID_MAX", 600100000UL); count = getdef_ulong ("SUB_GID_COUNT", 10000); - if (min >= max || count >= max || (min + count) >= max) { + if (min > max || count >= max || (min + count - 1) > max) { (void) fprintf (stderr, _("%s: Invalid configuration: SUB_GID_MIN (%lu)," " SUB_GID_MAX (%lu), SUB_GID_COUNT (%lu)\n"), diff --git a/libmisc/find_new_sub_uids.c b/libmisc/find_new_sub_uids.c index 35f5f90fb..525408ce6 100644 --- a/libmisc/find_new_sub_uids.c +++ b/libmisc/find_new_sub_uids.c @@ -60,7 +60,7 @@ int find_new_sub_uids (const char *owner, max = getdef_ulong ("SUB_UID_MAX", 600100000UL); count = getdef_ulong ("SUB_UID_COUNT", 10000); - if (min >= max || count >= max || (min + count) >= max) { + if (min > max || count >= max || (min + count - 1) > max) { (void) fprintf (stderr, _("%s: Invalid configuration: SUB_UID_MIN (%lu)," " SUB_UID_MAX (%lu), SUB_UID_COUNT (%lu)\n"),