summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas François <nicolas.francois@centraliens.net>2013-08-13 00:11:24 +0200
committerNicolas François <nicolas.francois@centraliens.net>2013-08-13 00:11:24 +0200
commitbfbd83239e55dd8e8ba351cb4fa18359c85cc996 (patch)
tree39df0e8263529825b7e2cf4135dee8bf4c241705
parentd9d1bb4acbacaccb53831ef95365ddba5a32ef73 (diff)
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.
-rw-r--r--ChangeLog6
-rw-r--r--lib/subordinateio.c4
-rw-r--r--libmisc/find_new_sub_gids.c2
-rw-r--r--libmisc/find_new_sub_uids.c2
4 files changed, 10 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 42483eb7..c2ef35f9 100644
--- 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
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"),