]> granicus.if.org Git - shadow/commitdiff
Fix handling of boundaries.
authorNicolas François <nicolas.francois@centraliens.net>
Mon, 12 Aug 2013 22:11:24 +0000 (00:11 +0200)
committerNicolas François <nicolas.francois@centraliens.net>
Mon, 12 Aug 2013 22:11:24 +0000 (00:11 +0200)
* lib/subordinateio.c: Fix handling of boundaries.
* libmisc/find_new_sub_uids.c: Likewise.
* libmisc/find_new_sub_gids.c: Likewise.

ChangeLog
lib/subordinateio.c
libmisc/find_new_sub_gids.c
libmisc/find_new_sub_uids.c

index 42483eb777d07ac14d52c1fef75aa8cf80a952b6..c2ef35f9f2537ef52d42028ca5a1aa8519ff532b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2013-08-13  Nicolas François  <nicolas.francois@centraliens.net>
+
+       * 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  <nicolas.francois@centraliens.net>
 
        * lib/subordinateio.c: Fix removal of ranges. The database needs
index 34630f2c608e43bf522ee0cf9f6e0cc94a92a3c6..4e94104c0295bebd960faf4dd3faddf2a3b33f7e 100644 (file)
@@ -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 */
index 1b008fbe9f51955c2557bda4d139a65ec0a3914f..5d12d9ac2db39c103f07c6952156f77d8f6a455b 100644 (file)
@@ -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"),
index 35f5f90fb3b12b93222b414d99a1f136bf191161..525408ce6d3738dcd45e95a11af9757bca11c934 100644 (file)
@@ -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"),