]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/subordinateio.c: Don't rely on id_t being unsigned
authorAlejandro Colomar <alx@kernel.org>
Wed, 8 Jul 2026 23:20:02 +0000 (01:20 +0200)
committerAlejandro Colomar <foss+github@alejandro-colomar.es>
Thu, 9 Jul 2026 20:45:02 +0000 (22:45 +0200)
POSIX doesn't provide any guarantees about the signedness of id_t.

Reported-by: Serge Hallyn <serge@hallyn.com>
Fixes: de7f1c78f70f (2026-04-09; "lib/subordinateio.c: find_free_range(): Use id_t instead of u_long")
Reviewed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/subordinateio.c

index 65bcfb7077882253de3263fa88485e70890955a9..c900ebc34a1a7529fc3245208a13be10d3bba0f0 100644 (file)
@@ -28,6 +28,7 @@
 #include "string/sprintf/stprintf.h"
 #include "string/strcmp/streq.h"
 #include "string/strtok/strsep2arr.h"
+#include "typetraits.h"
 
 
 #define ID_SIZE 31
@@ -1044,7 +1045,7 @@ bool new_subid_range(struct subordinate_range *range, enum subid_type id_type, b
                }
        }
 
-       start = find_free_range(db, range->start, -1, range->count);
+       start = find_free_range(db, range->start, maxof(id_t), range->count);
        if (start == -1) {
                ret = false;
                goto out;