X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb/blobdiff_plain/98421fc1a6832ad5de4b3f6171852437aa3e0fb2..a90d420cbe87490c844ae422c966e746d3134b07:/rand/noise.c diff --git a/rand/noise.c b/rand/noise.c index de120d8b..c120e6f2 100644 --- a/rand/noise.c +++ b/rand/noise.c @@ -217,7 +217,7 @@ int noise_devrandom(rand_pool *r) /* --- OpenBSD-flavoured shinies --- */ while (n < sizeof(buf)) { - nn = sizeof(buf) - nn; + nn = sizeof(buf) - n; if (nn > 256) nn = 256; if (getentropy(buf + n, nn)) break; n += nn; @@ -388,16 +388,15 @@ int noise_filter(rand_pool *r, int good, const char *c) /* --- Play games with uids --- */ if (noise_gid != NOISE_NOSETGID) { - setgid(noise_gid); - setegid(noise_gid); + if (setgid(noise_gid) || setegid(noise_gid) #ifdef HAVE_SETGROUPS - setgroups(1, &noise_gid); + || setgroups(1, &noise_gid) #endif + ) _exit(127); } if (noise_uid != NOISE_NOSETUID) { - setuid(noise_uid); - seteuid(noise_uid); + if (setuid(noise_uid) || seteuid(noise_uid)) _exit(127); } /* --- Start the process up --- */