Skip to contentSkip to conversation

ntfs: Replace struct ntfs_name 0-sized array with flexible array

PATCH New Kees Cook 1 participant 1 message Feb 16, 2024 NTFS filesystem

lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 ntfs: Replace struct ntfs_name 0-sized array with flexible array

ntfs_name::name is used as a destination in memcpy(), so it cannot be a 0-sized array any more. Convert it to a flexible array and annotated with __counted_by, which matches the allocations.

---
Cc: Anton Altaparmakov <[email protected]>
Cc: Namjae Jeon <[email protected]>
Cc: "Gustavo A. R. Silva" <[email protected]>
Cc: [email protected]
Cc: [email protected]

---
 fs/ntfs/dir.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ntfs/dir.h +1 -1
index 0e326753df40..cafcd339094c 100644
@@ -22,7 +22,7 @@ typedef struct {
 	MFT_REF mref;
 	FILE_NAME_TYPE_FLAGS type;
 	u8 len;
-	ntfschar name[0];
+	ntfschar name[] __counted_by(len);
 } __attribute__ ((__packed__)) ntfs_name;
 
 /* The little endian Unicode string $I30 as a global constant. */
Signature · 1 line
2.34.1