diff --git a/ChangeLog b/ChangeLog index 42483eb7..c2ef35f9 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 34630f2c..4e94104c 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 1b008fbe..5d12d9ac 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 35f5f90f..525408ce 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"),