From 262a0559ac416d0ceca31f7719253e0eb4cb4ab5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Pierre=20Andr=C3=A9?= Date: Mon, 20 Aug 2012 13:57:00 +0200 Subject: [PATCH] Fixed the computation of named attributes sizes in mkntfs The named attributes sizes were wrongly computed in mkntfs. This did not lead to visible errors so far owing to 8-byte alignments in attribute records (current names $SDS, $R, $O, etc). --- ntfsprogs/mkntfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ntfsprogs/mkntfs.c b/ntfsprogs/mkntfs.c index b468b2bc..ecff660e 100644 --- a/ntfsprogs/mkntfs.c +++ b/ntfsprogs/mkntfs.c @@ -1788,7 +1788,7 @@ static int insert_resident_attr_in_mft_record(MFT_RECORD *m, } a = ctx->attr; /* sizeof(resident attribute record header) == 24 */ - asize = ((24 + ((name_len + 7) & ~7) + val_len) + 7) & ~7; + asize = ((24 + ((name_len*2 + 7) & ~7) + val_len) + 7) & ~7; err = make_room_for_attribute(m, (char*)a, asize); if (err == -ENOSPC) { /* @@ -1831,7 +1831,7 @@ static int insert_resident_attr_in_mft_record(MFT_RECORD *m, m->next_attr_instance = cpu_to_le16((le16_to_cpu(m->next_attr_instance) + 1) & 0xffff); a->value_length = cpu_to_le32(val_len); - a->value_offset = cpu_to_le16(24 + ((name_len + 7) & ~7)); + a->value_offset = cpu_to_le16(24 + ((name_len*2 + 7) & ~7)); a->resident_flags = res_flags; a->reservedR = 0; if (name_len)