]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
usermod: refuse invalid uidmaps during --add-sub{u,g}ids
authorTycho Andersen <tycho@tycho.pizza>
Tue, 13 Feb 2024 21:30:12 +0000 (14:30 -0700)
committerSerge Hallyn <serge@hallyn.com>
Tue, 13 Feb 2024 22:06:23 +0000 (16:06 -0600)
It is slightly confusing to allow adding these only to later refuse them.

Here is a (lightly tested :) patch to also refuse them when adding.

Signed-off-by: Tycho Andersen <tycho@tycho.pizza>
src/usermod.c

index d42dbf8c7ee4e38c6219f0d7f17d9794ca00f3d2..3c271d8f53c506cd35ece68b432209a833683a31 100644 (file)
@@ -331,6 +331,13 @@ static struct ulong_range getulong_range(const char *str)
        if (first > last)
                goto out;
 
+       /*
+        * uid_t in linux is an unsigned int, anything over this is an invalid
+        * range will be later refused anyway by get_map_ranges().
+        */
+       if (first > UINT_MAX || last > UINT_MAX)
+               goto out;
+
        result.first = (unsigned long)first;
        result.last = (unsigned long)last;
 out: