Repository navigation
Description
Problem
The record reader (mainframe_boundary.py, _records) searches for a data entry's USAGE in window, which runs from the entry's name to the next level number or _ENTRY_LIMIT (600 chars). It does not stop at the entry's separator period. For the last DATA DIVISION entry, the window runs into the PROCEDURE DIVISION. So the first usage word there becomes the entry's USAGE: a DISPLAY verb, or a usage word inside a literal (MOVE 'BINARY' TO ...).
# mainframe_boundary.py (main 25f92338), ~l.1029-1035
entry = _ENTRY_END.split(_QUOTED.sub(..., window), maxsplit=1)[0] # cut at the period, literals blanked
if _NATIONAL_USAGE.search(entry): # NATIONAL already uses `entry`
usage = "NATIONAL"
else:
usage_match = _USAGE_CLAUSE.search(window) # every other usage still uses `window`The comment above it already says the last item's window "runs on into" the procedure, but only NATIONAL was moved onto entry.
Evidence
-
estate-crucible v0.1.0 (Epic: estate-crucible -- a synthetic mainframe estate whose answer key is generated with it #4317), keyed:
estate/apps/ACCT/cobol/ACCTUPD.cbl:16:01 WS-MSG PIC X(40).gets usageDISPLAY(taken fromDISPLAY WS-MSGin the procedure).estate/apps/ACCT/cobol/ACCTAUD.cbl:9:01 LK-UPD-CONTROL.(a group, thenCOPY UPDCTL.) getsDISPLAYtoo.
-
Minimal reproducers, main 25f9233.
WS-MSGgets usageDISPLAY:
IDENTIFICATION DIVISION. PROGRAM-ID. USGLEAK. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-COUNT PIC 9(4) VALUE 0. 01 WS-MSG PIC X(40). PROCEDURE DIVISION. MAIN-PARA. MOVE 'HELLO' TO WS-MSG DISPLAY WS-MSG GOBACK.
- Worse, a literal in the procedure changes the storage.
WS-LEN PIC 9(4)gets usageBINARY, andGalaxyIR.record_layoutgives 2 bytes instead of 4:
IDENTIFICATION DIVISION. PROGRAM-ID. USGBIN. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-MODE PIC X(8). 01 WS-LEN PIC 9(4). PROCEDURE DIVISION. MAIN-PARA. MOVE 'BINARY' TO WS-MODE MOVE 12 TO WS-LEN GOBACK.
Impact
Every program's last WORKING-STORAGE / LINKAGE entry is exposed. When the first usage word after it is DISPLAY, the result happens to be harmless for an alphanumeric item. When it is COMP / BINARY / PACKED-DECIMAL / INDEX / POINTER (as a word or inside a literal), the item's byte length is wrong. That flows into record layouts, COMMAREA contracts (LINKAGE is usually last), and translated Java field types.
Acceptance criteria
- USAGE (and any other clause the reader takes from
window) is searched only inentry: the entry's own text, up to its separator period, with literals blanked. - Both reproducers:
WS-MSGusage None,WS-LENusage None and layout 4 bytes. - estate-crucible: the
data_itemschecks for ACCTUPDWS-MSGand ACCTAUDLK-UPD-CONTROLpass.
Related: #3246 (record_data), #3816 (the NATIONAL fix that already uses entry), #4317 (estate-crucible; planted there as H-0009 from v0.2.0).
Found by: estate-crucible v0.1.0 scorecard (#4324).
Activity
fix(forge): name a LINKed program's COMMAREA DTO after its own DFHCOM…
fix: train -- #4329, #4391, #4392, #4393 (#4398)
squid-protocol commentedon Oct 5, 2026
Fixed by train D, #4398 (merged).