diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2015-12-28 05:21:54 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2015-12-28 05:21:54 +0000 |
commit | 07cc2c23d6c69a2fe51d83867966c1dac500754f (patch) | |
tree | bd5a528f7c2181cf5be4f40b5a9c7f6334bf361e /sys/dev | |
parent | e56ef0ae0306cc86890b20f3438c4b077e2cc818 (diff) |
use ulmin when looking at uio_resid to prevent wrapping around.
from Martin Natano (and also reported by Stefan Kempf)
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/rnd.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/dev/rnd.c b/sys/dev/rnd.c index ed84f239cfb..6f30b9e47ae 100644 --- a/sys/dev/rnd.c +++ b/sys/dev/rnd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rnd.c,v 1.176 2015/10/27 11:13:06 mikeb Exp $ */ +/* $OpenBSD: rnd.c,v 1.177 2015/12/28 05:21:53 tedu Exp $ */ /* * Copyright (c) 2011 Theo de Raadt. @@ -840,7 +840,7 @@ randomread(dev_t dev, struct uio *uio, int ioflag) } while (ret == 0 && uio->uio_resid > 0) { - int n = min(POOLBYTES, uio->uio_resid); + int n = ulmin(POOLBYTES, uio->uio_resid); if (myctx) { #ifndef KEYSTREAM_ONLY @@ -872,7 +872,7 @@ randomwrite(dev_t dev, struct uio *uio, int flags) buf = malloc(POOLBYTES, M_TEMP, M_WAITOK); while (ret == 0 && uio->uio_resid > 0) { - int n = min(POOLBYTES, uio->uio_resid); + int n = ulmin(POOLBYTES, uio->uio_resid); ret = uiomovei(buf, n, uio); if (ret != 0) |