mirror of
https://github.com/morluto/rea.git
synced 2026-11-18 20:53:00 +00:00
fix(ntfs): reject invalid FILE_NAME namespaces (#11986)
Co-authored-by: ShuaixinHuang <197200901+ShuaixinHuang@users.noreply.github.com>
This commit is contained in:
1 parent
3f1473065a
commit
f52229a4a6
2 files changed
+20
-1
No files matched your search
@@ -82,6 +82,20 @@ it.each([48, 72])(
|
||||
},
|
||||
);
|
||||
|
||||
it("rejects a FILE_NAME attribute with an undefined namespace", () => {
|
||||
const value = Buffer.alloc(66);
|
||||
value[65] = 4;
|
||||
const result = scan(resident(0x30, value));
|
||||
expect(result).toMatchObject({
|
||||
attributeCoverage: "incomplete",
|
||||
attributeIssue: {
|
||||
kind: "malformed",
|
||||
message: "FILE_NAME namespace is outside the NTFS range",
|
||||
},
|
||||
fileNames: [],
|
||||
});
|
||||
});
|
||||
|
||||
it("retains fragmented and sparse mapping pairs and lossless nonresident sizes without reading a volume", () => {
|
||||
const attribute = nonresident();
|
||||
const original = Buffer.from(attribute);
|
||||
|
||||
@@ -459,11 +459,16 @@ export const readMftAttributes = (
|
||||
malformed(cursor, "FILE_NAME string exceeds its value");
|
||||
break;
|
||||
}
|
||||
const namespace = record[valueOffset + 65]!;
|
||||
if (namespace > 3) {
|
||||
malformed(cursor, "FILE_NAME namespace is outside the NTFS range");
|
||||
break;
|
||||
}
|
||||
fileNames.push({
|
||||
fileOffset: fileOffset + valueOffset,
|
||||
parent: decodeMftFileReference(record.readBigUInt64LE(valueOffset)),
|
||||
...readTimes(record.subarray(valueOffset + 8)),
|
||||
namespace: record[valueOffset + 65]!,
|
||||
namespace,
|
||||
name: record.toString(
|
||||
"utf16le",
|
||||
valueOffset + 66,
|
||||
|
||||
Reference in new issue
Block a user