From 7a0cf11e1c4dd162828e36f3a5a3d12d7f20d88c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Pierre=20Andr=C3=A9?= Date: Sat, 11 Feb 2017 10:58:46 +0100 Subject: [PATCH] Fixed expanding $STANDARD_INFORMATION with almost-full MFT record When setting a security descriptor on an NTFS v1.2 format file in an NTFS v3.0+ volume, NTFS-3G would migrate $STANDARD_INFORMATION to the new format, which requires extending its size from 48 to 72 bytes. If this happened while the file's MFT record was almost full, and none of the file's attributes could be made non-resident, and the file did not have an attribute list attribute, then the operation would unexpectedly fail with ENOENT. Fix this by adding an attribute list to the file in this situation. (contributed by Eric Biggers) --- libntfs-3g/attrib.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libntfs-3g/attrib.c b/libntfs-3g/attrib.c index df1badad..30a8e9cf 100644 --- a/libntfs-3g/attrib.c +++ b/libntfs-3g/attrib.c @@ -5142,6 +5142,10 @@ static int ntfs_resident_attr_resize_i(ntfs_attr *na, const s64 newsize, */ if (na->type==AT_STANDARD_INFORMATION || na->type==AT_ATTRIBUTE_LIST) { ntfs_attr_put_search_ctx(ctx); + if (!NInoAttrList(na->ni) && ntfs_inode_add_attrlist(na->ni)) { + ntfs_log_perror("Could not add attribute list"); + return -1; + } if (ntfs_inode_free_space(na->ni, offsetof(ATTR_RECORD, non_resident_end) + 8)) { ntfs_log_perror("Could not free space in MFT record"); -- 2.11.0