From 03004ec6ba095cb3f5837fdfb6a5d2e7eb23b246 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sun, 6 Dec 2026 01:45:01 +0800 Subject: [PATCH] refactor(labview): reuse the checked section table extent (#17171) --- src/labview/LabviewRsrc.ts | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/labview/LabviewRsrc.ts b/src/labview/LabviewRsrc.ts index 36ba5523efa..5e3bf71ef98 100644 --- a/src/labview/LabviewRsrc.ts +++ b/src/labview/LabviewRsrc.ts @@ -388,7 +388,8 @@ export const parseLabviewRsrc = ( "RSRC section-start table overlaps the block headers", { offset: headerAt + 8, field: identifier }, ); - if (!inside(startsAt, sectionCount * SECTION_START_BYTES, listEnd)) + const tableBytes = sectionCount * SECTION_START_BYTES; + if (!inside(startsAt, tableBytes, listEnd)) throw truncatedInput(FORMAT, "truncated RSRC section starts", { offset: startsAt, field: identifier, @@ -416,17 +417,8 @@ export const parseLabviewRsrc = ( ), { offset: headerAt + 4, field: identifier }, ); - namesBase = Math.max( - namesBase, - startsAt + sectionCount * SECTION_START_BYTES, - ); + namesBase = Math.max(namesBase, startsAt + tableBytes); } - if (namesBase > listEnd) - throw truncatedInput( - FORMAT, - "RSRC section-name list exceeds the declared list", - { offset: namesBase }, - ); for (let blockIndex = 0; blockIndex < blockCount; blockIndex += 1) { const headerAt = blockHeadersAt + blockIndex * BLOCK_HEADER_BYTES;