From 8934e4707d9693588aa1b7a2f22c76e50e73b0cd Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Fri, 13 Sep 2002 09:00:28 +0000 Subject: [PATCH] * syscalls.cc (seteuid32): Treat ILLEGAL_UID invalid. (setegid32): Treat ILLEGAL_GID invalid. --- winsup/cygwin/ChangeLog | 5 +++++ winsup/cygwin/syscalls.cc | 20 ++++++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 4f02920a5..13902b1d0 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2002-09-13 Corinna Vinschen + + * syscalls.cc (seteuid32): Treat ILLEGAL_UID invalid. + (setegid32): Treat ILLEGAL_GID invalid. + 2002-09-10 Pierre Humblet * grp.cc (initgroups): Call groups::clear_supp to free the diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 657a40cfc..8c2b96b7b 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -1943,14 +1943,18 @@ seteuid32 (__uid32_t uid) debug_printf ("uid: %d myself->gid: %d", uid, myself->gid); if (!wincap.has_security () - || (uid == myself->uid - && !cygheap->user.groups.ischanged) - || uid == ILLEGAL_UID) + || (uid == myself->uid && !cygheap->user.groups.ischanged)) { debug_printf ("Nothing happens"); return 0; } + if (uid == ILLEGAL_UID) + { + set_errno (EINVAL); + return -1; + } + sigframe thisframe (mainthread); cygsid usersid; user_groups &groups = cygheap->user.groups; @@ -2122,11 +2126,15 @@ setuid (__uid16_t uid) extern "C" int setegid32 (__gid32_t gid) { - if ((!wincap.has_security ()) || - (gid == myself->gid) || - (gid == ILLEGAL_GID)) + if (!wincap.has_security () || gid == myself->gid) return 0; + if (gid == ILLEGAL_GID) + { + set_errno (EINVAL); + return -1; + } + sigframe thisframe (mainthread); user_groups * groups = &cygheap->user.groups; cygsid gsid;