diff options
author | Matthieu Herrb <matthieu@deville.herrb.com> | 2006-06-20 21:07:53 +0200 |
---|---|---|
committer | Matthieu Herrb <matthieu@deville.herrb.com> | 2006-06-20 21:07:53 +0200 |
commit | 2b58685402e70f123e131fd8146e6083ff5214a4 (patch) | |
tree | 4f05d7fce33826380f05c9a8d9a7c1f2bcdfc2c1 /os | |
parent | 4365d16c8629e824973ee0c357efdfbfd28b672c (diff) |
Check setuid() return value. Bugzilla #7116.
Diffstat (limited to 'os')
-rw-r--r-- | os/utils.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/os/utils.c b/os/utils.c index 43c6365a4..617d20119 100644 --- a/os/utils.c +++ b/os/utils.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xserver/xorg/os/utils.c,v 1.25 2006/03/25 19:52:05 ajax Exp $ */ +/* $XdotOrg: xserver/xorg/os/utils.c,v 1.26 2006-06-01 22:06:41 daniels Exp $ */ /* $Xorg: utils.c,v 1.5 2001/02/09 02:05:24 xorgcvs Exp $ */ /* @@ -1713,8 +1713,10 @@ System(char *command) case -1: /* error */ p = -1; case 0: /* child */ - setgid(getgid()); - setuid(getuid()); + if (setgid(getgid()) == -1) + _exit(127); + if (setuid(getuid()) == -1) + _exit(127); execl("/bin/sh", "sh", "-c", command, (char *)NULL); _exit(127); default: /* parent */ @@ -1765,8 +1767,10 @@ Popen(char *command, char *type) xfree(cur); return NULL; case 0: /* child */ - setgid(getgid()); - setuid(getuid()); + if (setgid(getgid()) == -1) + _exit(127); + if (setuid(getuid()) == -1) + _exit(127); if (*type == 'r') { if (pdes[1] != 1) { /* stdout */ @@ -1840,8 +1844,10 @@ Fopen(char *file, char *type) xfree(cur); return NULL; case 0: /* child */ - setgid(getgid()); - setuid(getuid()); + if (setgid(getgid()) == -1) + _exit(127); + if (setuid(getuid()) == -1) + _exit(127); if (*type == 'r') { if (pdes[1] != 1) { /* stdout */ |