From 1dbb7df5ccec3e3d9fecded33850730486d6374d Mon Sep 17 00:00:00 2001 From: Matthieu Herrb Date: Tue, 20 Jun 2006 19:25:51 +0000 Subject: Check setuid() return value. Bugzilla #7116. --- ChangeLog | 5 +++++ xload.c | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index f782e91..a637939 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-06-20 Matthieu Herrb + + * xload.c: + Check setuid() return value. Bugzilla #7116. + 2005-12-20 Kevin E. Martin * configure.ac: diff --git a/xload.c b/xload.c index 65595f0..2dc1cb3 100644 --- a/xload.c +++ b/xload.c @@ -34,7 +34,7 @@ from the X Consortium. * xload - display system load average in a window */ - +#include #include #include #include @@ -162,8 +162,17 @@ main(int argc, char **argv) /* For security reasons, we reset our uid/gid after doing the necessary system initialization and before calling any X routines. */ InitLoadPoint(); - setgid(getgid()); /* reset gid first while still (maybe) root */ - setuid(getuid()); + /* reset gid first while still (maybe) root */ + if (setgid(getgid()) == -1) { + fprintf(stderr, "%s: setgid failed: %s\n", + ProgramName, strerror(errno)); + exit(1); + } + if (setuid(getuid()) == -1) { + fprintf(stderr, "%s: setuid failed: %s\n", + ProgramName, strerror(errno)); + exit(1); + } XtSetLanguageProc(NULL, (XtLanguageProc) NULL, NULL); -- cgit v1.2.3