X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/blobdiff_plain/88bf1145bc9f8cad86e319cd78f2ed4afb7189ad..e54488bbec5c9f80e95cedd395b0e3d31fde253d:/sys/vfs/procfs/procfs_rlimit.c diff --git a/sys/vfs/procfs/procfs_rlimit.c b/sys/vfs/procfs/procfs_rlimit.c index 811f499e97..c2b015716b 100644 --- a/sys/vfs/procfs/procfs_rlimit.c +++ b/sys/vfs/procfs/procfs_rlimit.c @@ -61,16 +61,15 @@ procfs_dorlimit(struct proc *curp, struct lwp *lp, struct pfsnode *pfs, struct uio *uio) { struct proc *p = lp->lwp_proc; + size_t xlen; char *ps; - int i; - int xlen; int error; + int i; char psbuf[512]; /* XXX - conservative */ if (uio->uio_rw != UIO_READ) return (EOPNOTSUPP); - ps = psbuf; for (i = 0; i < RLIM_NLIMITS; i++) { @@ -114,10 +113,10 @@ procfs_dorlimit(struct proc *curp, struct lwp *lp, struct pfsnode *pfs, */ xlen = ps - psbuf; - xlen -= uio->uio_offset; - ps = psbuf + uio->uio_offset; - xlen = imin(xlen, uio->uio_resid); - if (xlen <= 0) + xlen -= (size_t)uio->uio_offset; + ps = psbuf + (size_t)uio->uio_offset; + xlen = szmin(xlen, uio->uio_resid); + if (xlen == 0) error = 0; else error = uiomove_frombuf(psbuf, xlen, uio);