From c87fc027dfd74ace2dd88dae930c09c96d15934a Mon Sep 17 00:00:00 2001 From: jpandre Date: Sat, 25 Apr 2009 12:02:20 +0000 Subject: [PATCH] Secured write position to compressed files --- libntfs-3g/attrib.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libntfs-3g/attrib.c b/libntfs-3g/attrib.c index 73cc5678..67c969f2 100644 --- a/libntfs-3g/attrib.c +++ b/libntfs-3g/attrib.c @@ -1502,7 +1502,8 @@ s64 ntfs_attr_pwrite(ntfs_attr *na, const s64 pos, s64 count, const void *b) goto err_out; } if (compressed) { - while (ofs >= (rl->length << vol->cluster_size_bits)) { + while (rl->length + && (ofs >= (rl->length << vol->cluster_size_bits))) { ofs -= rl->length << vol->cluster_size_bits; rl++; } @@ -1778,7 +1779,8 @@ int ntfs_attr_pclose(ntfs_attr *na) if (ntfs_attr_fill_hole(na, (s64)0, &ofs, &rl, &update_from)) goto err_out; } - while (ofs >= (rl->length << vol->cluster_size_bits)) { + while (rl->length + && (ofs >= (rl->length << vol->cluster_size_bits))) { ofs -= rl->length << vol->cluster_size_bits; rl++; }