diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 2000-10-20 03:30:07 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 2000-10-20 03:30:07 +0000 |
commit | 1075f06ec4f587b7d8a415f7deaeca8c198cabdc (patch) | |
tree | 7bc5caaab3d31e3ad9a6c9a9e20c735e0f71a23e /sys/dev/rnd.c | |
parent | 63fb7c0c6150b6699379b42de130c1a8dd37fba2 (diff) |
fix ioctls; pointed out by Pawel Krawczyk <http://ceti.pl/~kravietz/>
Diffstat (limited to 'sys/dev/rnd.c')
-rw-r--r-- | sys/dev/rnd.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/sys/dev/rnd.c b/sys/dev/rnd.c index 4df276058c1..4f750f7af2d 100644 --- a/sys/dev/rnd.c +++ b/sys/dev/rnd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rnd.c,v 1.43 2000/08/21 01:52:18 jason Exp $ */ +/* $OpenBSD: rnd.c,v 1.44 2000/10/20 03:30:05 mickey Exp $ */ /* * random.c -- A strong random number generator @@ -1037,7 +1037,7 @@ randomioctl(dev, cmd, data, flag, p) int flag; struct proc *p; { - int ret = 0; + int s, ret = 0; u_int cnt; add_timer_randomness((u_long)p ^ (u_long)data ^ cmd); @@ -1052,38 +1052,51 @@ randomioctl(dev, cmd, data, flag, p) break; case RNDGETENTCNT: - ret = copyout(&random_state.entropy_count, data, - sizeof(random_state.entropy_count)); + s = splhigh(); + *(u_int *)data = random_state.entropy_count; + splx(s); break; case RNDADDTOENTCNT: if (suser(p->p_ucred, &p->p_acflag) != 0) ret = EPERM; else { - copyin(&cnt, data, sizeof(cnt)); + cnt = *(u_int *)data; + printf("%d\n", cnt); + s = splhigh(); random_state.entropy_count += cnt; if (random_state.entropy_count > POOLBITS) random_state.entropy_count = POOLBITS; + splx(s); } break; case RNDZAPENTCNT: if (suser(p->p_ucred, &p->p_acflag) != 0) ret = EPERM; - else + else { + s = splhigh(); random_state.entropy_count = 0; + splx(s); + } break; case RNDSTIRARC4: if (suser(p->p_ucred, &p->p_acflag) != 0) ret = EPERM; else if (random_state.entropy_count < 64) ret = EAGAIN; - else + else { + s = splhigh(); arc4random_initialized = 0; + splx(s); + } break; case RNDCLRSTATS: if (suser(p->p_ucred, &p->p_acflag) != 0) ret = EPERM; - else + else { + s = splhigh(); bzero(&rndstats, sizeof(rndstats)); + splx(s); + } break; default: ret = EINVAL; |