Skip to content

Instantly share code, notes, and snippets.

@spiculator
Created June 18, 2014 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spiculator/281c923919de42530b93 to your computer and use it in GitHub Desktop.
Save spiculator/281c923919de42530b93 to your computer and use it in GitHub Desktop.
fix vulnarability in jail chroot tool
diff --git a/src/jail.c b/src/jail.c
index ecf0cb3..9b1da64 100644
--- a/src/jail.c
+++ b/src/jail.c
@@ -453,8 +453,14 @@ int main(int argc, char *argv[], char *env[]) {
// call the shell overriding current process space
//
- setgid(gid);
- setuid(uid);
+ if( 0 != setgid(gid) ) {
+ perror("setgid");
+ exit(EXIT_FAILURE);
+ }
+ if( 0 != setuid(uid) ) {
+ perror("setuid");
+ exit(EXIT_FAILURE);
+ }
#if DEBUG != 0
fprintf(stderr,"jail: doing chdir(%s)\n",ptr_home_dir);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment