2010-07-19 14:13:47 +02:00
|
|
|
While uid_t and gid_t are both unsigned, the values (uid_t) -1 and
|
|
|
|
(gid_t) -1 are reserved. A uid or gid argument of -1 to the chown(2)
|
|
|
|
system call means to leave the uid/gid unchanged. Catch this case
|
|
|
|
so that trying to set a uid or gid to -1 will result in an error.
|
|
|
|
|
|
|
|
Test cases:
|
|
|
|
|
|
|
|
chown 4294967295 file
|
|
|
|
chown :4294967295 file
|
|
|
|
chgrp 4294967295 file
|
|
|
|
|
|
|
|
Andreas Gruenbacher <agruen@suse.de>
|
|
|
|
|
2014-01-10 21:15:22 +01:00
|
|
|
---
|
|
|
|
src/chgrp.c | 2 +-
|
|
|
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
|
|
2010-07-19 14:13:47 +02:00
|
|
|
Index: src/chgrp.c
|
|
|
|
===================================================================
|
2014-01-30 12:51:46 +01:00
|
|
|
--- src/chgrp.c.orig
|
|
|
|
+++ src/chgrp.c
|
2021-11-11 21:36:23 +01:00
|
|
|
@@ -89,7 +89,7 @@ parse_group (char const *name)
|
2010-07-19 14:13:47 +02:00
|
|
|
{
|
2020-03-25 23:41:44 +01:00
|
|
|
uintmax_t tmp;
|
|
|
|
if (! (xstrtoumax (name, NULL, 10, &tmp, "") == LONGINT_OK
|
2010-07-19 14:13:47 +02:00
|
|
|
- && tmp <= GID_T_MAX))
|
|
|
|
+ && tmp <= GID_T_MAX && (gid_t) tmp != (gid_t) -1))
|
2016-12-05 16:28:40 +01:00
|
|
|
die (EXIT_FAILURE, 0, _("invalid group: %s"),
|
|
|
|
quote (name));
|
2010-07-19 14:13:47 +02:00
|
|
|
gid = tmp;
|