diff options
author | phk <phk@FreeBSD.org> | 2005-01-25 09:15:32 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2005-01-25 09:15:32 +0000 |
commit | a4f3b3f60934f1115f7dd3689318b96b2632d1f0 (patch) | |
tree | dbecfd47dd9473cd90669440d1a4f9df25177118 /sys/kern | |
parent | 60893a88a86cf62edc2c3535dad0f5ca1145f963 (diff) | |
download | FreeBSD-src-a4f3b3f60934f1115f7dd3689318b96b2632d1f0.zip FreeBSD-src-a4f3b3f60934f1115f7dd3689318b96b2632d1f0.tar.gz |
Previously a read of zero bytes got handled in devfs:vop_read() but I
missed that when the vnode bypass was introduced.
Deal with zero length transfers before we even get to fo_ops->fo_read().
Found by: Slawa Olhovchenkov <slwzxy.spb.ru@zxy.spb.ru>
PR: 75758
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/sys_generic.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c index 0aa178a..421f2e0 100644 --- a/sys/kern/sys_generic.c +++ b/sys/kern/sys_generic.c @@ -167,6 +167,11 @@ dofileread(td, fp, fd, buf, nbyte, offset, flags) struct uio *ktruio = NULL; #endif + /* Finish zero length reads right here */ + if (nbyte == 0) { + td->td_retval[0] = 0; + return(0); + } aiov.iov_base = buf; aiov.iov_len = nbyte; auio.uio_iov = &aiov; @@ -232,6 +237,13 @@ readv(struct thread *td, struct readv_args *uap) fdrop(fp, td); return (error); } + /* Finish zero length reads right here */ + if (auio->uio_resid == 0) { + td->td_retval[0] = 0; + free(auio, M_IOV); + fdrop(fp, td); + return(0); + } auio->uio_rw = UIO_READ; auio->uio_td = td; #ifdef KTRACE |