fix(native): raise default PE resource entry budget to 16384 (#1703)

inspect-pe-resources rejected stock Windows resource images because their
tables exceed the 4096-entry default. Windows 11 25H2 SystemResources
measures imageres.dll.mun at 6476 examined entries, shell32.dll.mun at 5903
and wmploc.DLL.mun at 5440, so the default budget now admits each of them
with headroom while the maximum stays 65536. The independent 8 MiB metadata
budget still bounds allocation, and exceeding any budget still fails without
partial results.

The stable filesystem boundary test now emits a 6476-entry table through a
larger fixture section and asserts that the default budgets report complete
coverage, covering stock-image scale without a real Windows file.
This commit is contained in:
Jason Cat
2026-10-11 19:01:33 +08:00
committed by GitHub
parent 3ad5782dfd
commit 951c2aae3b
4 changed files with 46 additions and 3 deletions
+6 -1
View File
@@ -22,12 +22,17 @@ export const inspectPeResourcesInputSchema = z.strictObject({
.max(536870912)
.default(67108864)
.describe("Maximum stable artifact bytes to read (default 64 MiB)"),
// Windows resource images carry thousands of entries: Windows 11 25H2
// SystemResources measures imageres.dll.mun at 6476 examined entries,
// shell32.dll.mun at 5903 and wmploc.DLL.mun at 5440. The default admits
// those stock images with headroom; the independent 8 MiB metadata budget
// still bounds allocation.
max_entries: z
.number()
.int()
.min(1)
.max(65536)
.default(4096)
.default(16384)
.describe(
"Maximum resource directory entries to examine; exceeding the budget fails without partial success",
),
+2 -1
View File
@@ -37,6 +37,7 @@ export const peResourceFixture = (
{ type: 10, name: 7, language: 1041, payload: Buffer.from("World") },
{ type: 14, name: 42, language: 1033, payload: iconGroup() },
],
sectionBytes = 65536,
) => {
const tree: Tree = { children: new Map() };
for (const resource of resources) {
@@ -58,7 +59,7 @@ export const peResourceFixture = (
if ("children" in child.value) parent = child.value;
}
}
const section = Buffer.alloc(65536);
const section = Buffer.alloc(sectionBytes);
let cursor = 0;
const allocate = (size: number, alignment = 4): number => {
cursor = Math.ceil(cursor / alignment) * alignment;