]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Don't forget to check the return values of setuid and friends.
authorSimon Tatham <anakin@pobox.com>
Sat, 23 Feb 2013 21:00:29 +0000 (21:00 +0000)
committerSimon Tatham <anakin@pobox.com>
Sat, 23 Feb 2013 21:00:29 +0000 (21:00 +0000)
[originally from svn r9764]

unix/uxpty.c

index a1f96946e3879971404d74ac190c1bb18aa0eecc..2bfb85b58a702ef7abf583d6654c4688f67927b7 100644 (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
     }
 }