]> git.saurik.com Git - apple/xnu.git/blobdiff - iokit/Families/IOStorage/IOBlockStorageDriver.cpp
xnu-124.13.tar.gz
[apple/xnu.git] / iokit / Families / IOStorage / IOBlockStorageDriver.cpp
index 8e843b49a5b5fa9473039b432f1900f6a572d19a..345e55b5610a68bed4e3465f3a1adc524b425b24 100644 (file)
@@ -1759,7 +1759,7 @@ IOByteCount IODeblocker::readBytes( IOByteCount offset,
 
     for ( ; index < _chunksCount && withLength; index++)
     {
-        IOByteCount copy   = min(_chunks[index].length, withLength);
+        IOByteCount copy   = min(_chunks[index].length - offset, withLength);
         IOByteCount copied = _chunks[index].buffer->readBytes(
                                     /* offset */ offset + _chunks[index].offset,
                                     /* bytes  */ bytes,
@@ -1798,7 +1798,7 @@ IOByteCount IODeblocker::writeBytes( IOByteCount  offset,
 
     for ( ; index < _chunksCount && withLength; index++)
     {
-        IOByteCount copy   = min(_chunks[index].length, withLength);
+        IOByteCount copy   = min(_chunks[index].length - offset, withLength);
         IOByteCount copied = _chunks[index].buffer->writeBytes(
                                     /* offset */ offset + _chunks[index].offset,
                                     /* bytes  */ bytes,