forked from pool/coreutils
091187f8d9
Update to 8.22 OBS-URL: https://build.opensuse.org/request/show/212838 OBS-URL: https://build.opensuse.org/package/show/Base:System/coreutils?expand=0&rev=219
31 lines
1.0 KiB
Diff
31 lines
1.0 KiB
Diff
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>
|
|
|
|
---
|
|
src/chgrp.c | 2 +-
|
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
|
Index: src/chgrp.c
|
|
===================================================================
|
|
--- src/chgrp.c.orig 2014-01-03 18:18:24.257902746 +0100
|
|
+++ src/chgrp.c 2014-01-03 19:47:23.019440368 +0100
|
|
@@ -88,7 +88,7 @@ parse_group (const char *name)
|
|
{
|
|
unsigned long int tmp;
|
|
if (! (xstrtoul (name, NULL, 10, &tmp, "") == LONGINT_OK
|
|
- && tmp <= GID_T_MAX))
|
|
+ && tmp <= GID_T_MAX && (gid_t) tmp != (gid_t) -1))
|
|
error (EXIT_FAILURE, 0, _("invalid group: %s"), quote (name));
|
|
gid = tmp;
|
|
}
|