3
0
forked from pool/coreutils
coreutils/coreutils-invalid-ids.patch
Stephan Kulow d326a25e75 Accepting request 149348 from Base:System
- Avoid segmentation fault in "join -i" with long line input (bnc#798541, VUL-1)
- Avoid segmentation fault in "sort -d" and "sort -M" with long line input
  (bnc#798538, VUL-1)
- Avoid segmentation fault in "uniq" with long line input (bnc#796243, VUL-1)
- Fix test-suite errors (bnc#798261).

OBS-URL: https://build.opensuse.org/request/show/149348
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/coreutils?expand=0&rev=84
2013-01-22 14:08:43 +00:00

27 lines
900 B
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>
Index: src/chgrp.c
===================================================================
--- src/chgrp.c.orig
+++ src/chgrp.c
@@ -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;
}