summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/fs/ntfs/ntfs_subr.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/sys/fs/ntfs/ntfs_subr.c b/sys/fs/ntfs/ntfs_subr.c
index 68f654f2fa08..814a91e2075a 100644
--- a/sys/fs/ntfs/ntfs_subr.c
+++ b/sys/fs/ntfs/ntfs_subr.c
@@ -1544,6 +1544,20 @@ ntfs_readntvattr_plain(
min(ntfs_cntob(ccl) - off,
MAXBSIZE - off));
cl = ntfs_btocl(tocopy + off);
+
+ /*
+ * If 'off' pushes us to next
+ * block, don't attempt to read whole
+ * 'tocopy' at once. This is to avoid
+ * bread() with varying 'size' for
+ * same 'blkno', which is not good.
+ */
+ if (cl > ntfs_btocl(tocopy)) {
+ tocopy -=
+ ntfs_btocnoff(tocopy + off);
+ cl--;
+ }
+
ddprintf(("ntfs_readntvattr_plain: " \
"read: cn: 0x%x cl: %d, " \
"off: %d len: %d, left: %d\n",
@@ -1587,7 +1601,7 @@ ntfs_readntvattr_plain(
off = 0;
if (uio) {
size_t remains = tocopy;
- for(; remains; remains++)
+ for(; remains; remains--)
uiomove("", 1, uio);
} else
bzero(data, tocopy);