From: Derrick Brashear Date: Thu, 29 Nov 2007 18:32:29 +0000 (+0000) Subject: zero-uio-on-zero-read-20071127 X-Git-Tag: BP-openafs-windows-kdfs-ifs~323 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=262d1d1c70222b8378109674cd5090f602c52971;p=packages%2Fo%2Fopenafs.git zero-uio-on-zero-read-20071127 LICENSE IPL10 avoid leaking random data in a read of a 0 length object. --- diff --git a/src/afs/VNOPS/afs_vnop_read.c b/src/afs/VNOPS/afs_vnop_read.c index 9a104e168..8089e6836 100644 --- a/src/afs/VNOPS/afs_vnop_read.c +++ b/src/afs/VNOPS/afs_vnop_read.c @@ -117,7 +117,21 @@ afs_MemRead(register struct vcache *avc, struct uio *auio, * Locks held: * avc->lock(R) */ - while (totalLength > 0) { + if (filePos >= avc->m.Length) { + if (len > AFS_ZEROS) + len = sizeof(afs_zeros); /* and in 0 buffer */ +#ifdef AFS_DARWIN80_ENV + trimlen = len; + tuiop = afsio_darwin_partialcopy(auio, trimlen); +#else + afsio_copy(auio, &tuio, tvec); + trimlen = len; + afsio_trim(&tuio, trimlen); +#endif + AFS_UIOMOVE(afs_zeros, trimlen, UIO_READ, tuiop, code); + } + + while (avc->m.Length > 0 && totalLength > 0) { /* read all of the cached info */ if (filePos >= avc->m.Length) break; /* all done */ @@ -536,7 +550,22 @@ afs_UFSRead(register struct vcache *avc, struct uio *auio, } #endif - while (totalLength > 0) { + if (filePos >= avc->m.Length) { + if (len > AFS_ZEROS) + len = sizeof(afs_zeros); /* and in 0 buffer */ + len = 0; +#ifdef AFS_DARWIN80_ENV + trimlen = len; + tuiop = afsio_darwin_partialcopy(auio, trimlen); +#else + afsio_copy(auio, &tuio, tvec); + trimlen = len; + afsio_trim(&tuio, trimlen); +#endif + AFS_UIOMOVE(afs_zeros, trimlen, UIO_READ, tuiop, code); + } + + while (avc->m.Length > 0 && totalLength > 0) { /* read all of the cached info */ if (filePos >= avc->m.Length) break; /* all done */