1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-04-11 16:18:06 -05:00

Don't forget to check the return values of setuid and friends.

[originally from svn r9764]
This commit is contained in:
Simon Tatham 2013-02-23 21:00:29 +00:00
parent 40ce043a97
commit 74bc2635ad

View File

@ -531,11 +531,23 @@ void pty_pre_init(void)
int gid = getgid(), uid = getuid();
int setresgid(gid_t, gid_t, gid_t);
int setresuid(uid_t, uid_t, uid_t);
setresgid(gid, gid, gid);
setresuid(uid, uid, uid);
if (setresgid(gid, gid, gid) < 0) {
perror("setresgid");
exit(1);
}
if (setresuid(uid, uid, uid) < 0) {
perror("setresuid");
exit(1);
}
#else
setgid(getgid());
setuid(getuid());
if (setgid(getgid()) < 0) {
perror("setgid");
exit(1);
}
if (setuid(getuid()) < 0) {
perror("setuid");
exit(1);
}
#endif
}
}