FA-78931 / Image orientation metadata / Open access
IFD entry ending exactly at the buffer end is rejected · case 01
Minimal EXIF blocks whose last entry ends at the payload end are reported as malformed.
ROOT CAUSE
The bounds test uses >=, rejecting an entry whose twelve bytes end exactly at the end of the data.
VERIFIED REPAIR
Reject only when e + 12 exceeds the buffer length.
Unsuccessful approach: Checking only eight bytes lets entries with a truncated value field through.
Case contract
Parse the orientation from an APP1 Exif payload given as a list of byte values: a 6-byte "Exif\0\0" header, then a TIFF header (II little-endian or MM big-endian, magic 42 as a 16-bit value, 32-bit IFD0 offset relative to the TIFF header). Scan IFD0 12-byte entries; the first entry with tag 0x0112, type SHORT (3) and count 1 supplies the value from the first two bytes of its value field. Values outside 1..8 and a missing entry yield 1; structural problems (short payload, bad header, byte order, magic, truncated entry) yield "malformed".
Why this case matters
Camera, phone and scanner images carry an orientation hint separately from the stored pixels; galleries, thumbnailers, editors and upload pipelines must interpret it consistently or photos appear sideways, mirrored or doubly rotated.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(data):
b = data
if len(b) < 14 or b[:6] != [69, 120, 105, 102, 0, 0]:
return 'malformed'
t = b[6:]
if t[:2] == [73, 73]:
le = True
elif t[:2] == [77, 77]:
le = False
else:
return 'malformed'
def u16(o):
if o + 2 > len(t):
return None
return t[o] | (t[o + 1] << 8) if le else (t[o] << 8) | t[o + 1]
def u32(o):
if o + 4 > len(t):
return None
v = t[o:o + 4]
if le:
v = v[::-1]
return (v[0] << 24) | (v[1] << 16) | (v[2] << 8) | v[3]
if u16(2) != 42:
return 'malformed'
ifd = u32(4)
count = u16(ifd)
if count is None:
return 'malformed'
for i in range(count):
e = ifd + 2 + 12 * i
if e + 12 >= len(t):
return 'malformed'
tag = u16(e)
typ = u16(e + 2)
cnt = u32(e + 4)
if tag == 0x0112 and typ == 3 and cnt == 1:
val = u16(e + 8)
return val if 1 <= val <= 8 else 1
return 1
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 8, 0, 3, 1, 15, 0, 3, 0, 0, 0, 1, 0, 7, 0, 0, 1, 26, 0, 3, 0, 0, 0, 1, 0, 114, 0, 0, 1, 18, 0, 3, 0, 0, 0, 1, 0, 0, 0, 0], 1], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 8, 0, 0, 0, 3, 0, 15, 1, 3, 0, 1, 0, 0, 0, 136, 0, 0, 0, 16, 1, 3, 0, 1, 0, 0, 0, 192, 1, 0, 0, 18, 1, 3, 0, 1, 0, 0, 0, 7, 0, 0], 'malformed'], [[69, 120, 105, 102, 0, 0, 73, 73, 0, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 26, 1, 3, 0, 1, 0, 0, 0, 126, 1, 0], 'malformed'], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 43, 0, 0, 0, 8, 0, 1, 1, 18, 0, 3, 0, 0, 0, 1, 0, 4, 0, 0, 0, 0, 0, 0], 'malformed'], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 10, 0, 0, 0, 0, 0, 2, 0, 15, 1, 3, 0, 1, 0, 0, 0, 73, 0, 0, 0, 26, 1, 3, 0, 1, 0, 0, 0, 37, 0, 0, 0, 0, 0, 0, 0], 1], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 8, 0, 0, 0, 2, 0, 16, 1, 3, 0, 1, 0, 0, 0, 247, 0, 0, 0, 15, 1, 3, 0, 1, 0, 0, 0, 124, 1, 0, 0, 0, 0, 0, 0], 1], [[69, 120, 105, 102, 0, 255, 77, 77, 0, 42, 0, 0, 0, 10, 0, 0, 0, 1, 1, 18, 0, 3, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], 'malformed'], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 8, 0, 0, 0, 2, 0, 15, 1, 3, 0, 1, 0, 0, 0, 137, 1, 0, 0, 18, 1, 3, 0, 1, 0, 0, 0, 5, 0, 0, 0], 5]], [[[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 8, 0, 0, 0, 2, 0, 16, 1, 3, 0, 1, 0, 0, 0, 87, 0, 0, 0, 26, 1, 3, 0, 1, 0, 0, 0, 107, 0, 0, 0], 1], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 8, 0, 4, 1, 18, 0, 3, 0, 0, 0, 2, 0, 6, 0, 0, 1, 15, 0, 3, 0, 0, 0, 1, 0, 31, 0, 0, 1, 16, 0, 3, 0, 0, 0, 1, 0, 202, 0, 0, 1, 16, 0, 3, 0, 0, 0, 1], 'malformed'], [[69, 120, 105, 102, 0, 255, 77, 77, 0, 42, 0, 0, 0, 14, 0, 0, 0, 0, 0, 0, 0, 2, 1, 18, 0, 3, 0, 0, 0, 1, 0, 1, 0, 0, 1, 26, 0, 3, 0, 0, 0, 1, 0, 46, 0, 0, 0, 0, 0, 0], 'malformed'], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 8, 0, 3, 1, 15, 0, 3, 0, 0, 0, 1, 1, 96, 0, 0, 1, 18, 0, 3, 0, 0, 0, 1, 0, 0, 0, 0, 1, 15, 0, 3, 0, 0, 0, 1, 1, 150], 1], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 10, 0, 0, 0, 0, 0, 3, 0, 26, 1, 3, 0, 1, 0, 0, 0, 115, 1, 0, 0, 16, 1, 3, 0, 1, 0, 0, 0, 111, 0, 0, 0, 18, 1, 3, 0, 1, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0], 8], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 10, 0, 0, 0, 5, 1, 18, 0, 4, 0, 0, 0, 2, 0, 0, 0, 8, 1, 26, 0, 3, 0, 0, 0, 1, 1, 15, 0, 0, 1, 15, 0, 3, 0, 0, 0, 1, 0, 190, 0, 0, 1, 18, 0, 3, 0, 0, 0, 1, 0, 6, 0, 0, 1, 15, 0, 3, 0, 0, 0, 1, 1, 77, 0, 0, 0, 0, 0, 0], 6], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 8, 0, 0, 0, 1, 0, 18, 1, 3, 0, 1, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0], 4], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 10, 0, 0, 0, 0, 0, 2, 0, 26, 1, 3, 0, 1, 0, 0, 0, 30, 0, 0, 0, 18, 1, 3, 0, 1, 0, 0, 0, 2, 0, 0, 0], 2]], [[[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 8, 0, 0, 0, 3, 0, 26, 1, 3, 0, 1, 0, 0, 0, 114, 1, 0, 0, 16, 1, 3, 0, 1, 0, 0, 0, 148, 1, 0, 0, 16, 1, 3, 0, 1, 0, 0, 0, 197, 0, 0, 0], 1], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 10, 0, 0, 0, 0, 0, 1, 0, 18, 1, 3, 0, 1, 0, 0, 0, 4, 0], 'malformed'], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 8, 0, 4, 1, 18, 0, 3, 0, 0, 0, 1, 0, 9, 0, 0, 1, 26, 0, 3, 0, 0, 0, 1, 1, 115, 0, 0, 1, 16, 0, 3, 0, 0, 0, 1, 1, 244, 0, 0, 1, 15, 0, 3, 0, 0, 0, 1, 1, 186, 0, 0, 0, 0, 0, 0], 1], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 1], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 18, 1, 3, 0, 1, 0, 0, 0, 8, 0, 0, 0, 15, 1, 3, 0, 1, 0, 0, 0, 202, 0, 0, 0, 15, 1, 3, 0, 1], 8], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 8, 0, 4, 1, 18, 0, 3, 0, 0, 0, 2, 0, 8, 0, 0, 1, 15, 0, 3, 0, 0, 0, 1, 0, 242, 0, 0, 1, 18, 0, 3, 0, 0, 0, 1, 0, 8, 0, 0, 1, 16, 0, 3, 0, 0, 0, 1, 1, 214, 0, 0, 0, 0, 0, 0], 8], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 10, 0, 0, 0, 4, 1, 18, 0, 3, 0, 0, 0, 2, 0, 3, 0, 0, 1, 18, 0, 3, 0, 0, 0, 1, 0, 6, 0, 0, 1, 15, 0, 3, 0, 0, 0, 1, 0, 195, 0, 0, 1, 26, 0, 3, 0, 0, 0, 1, 0, 238, 0, 0, 0, 0, 0, 0], 6], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 18, 1, 4, 0, 2, 0, 0, 0, 8, 0, 0, 0, 16, 1, 3, 0, 1, 0, 0, 0, 133, 1, 0, 0], 1]], [[[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 8, 0, 3, 1, 26, 0, 3, 0, 0, 0, 1, 0, 24, 0, 0, 1, 26, 0, 3, 0, 0, 0, 1, 0, 40, 0, 0, 1, 15, 0, 3, 0, 0, 0, 1, 1, 31, 0, 0], 1], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 8, 0, 3, 1, 16, 0, 3, 0, 0, 0, 1, 1, 163, 0, 0, 1, 26, 0, 3, 0, 0, 0, 1, 1, 29, 0, 0, 1, 15, 0, 3, 0, 0, 0, 1, 0, 18], 'malformed'], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 0, 0, 0, 0, 14, 0, 0, 0, 0, 0, 0, 0, 3, 1, 26, 0, 3, 0, 0, 0, 1, 1, 79, 0, 0, 1, 16, 0, 3, 0, 0, 0, 1, 1, 177, 0, 0, 1, 26, 0, 3, 0, 0], 'malformed'], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 8, 0, 0, 0, 3, 0, 26, 1, 3, 0, 1, 0, 0, 0, 17, 0, 0, 0, 15, 1, 3, 0, 1, 0, 0, 0, 37, 1, 0, 0, 15, 1, 3, 0, 1, 0, 0, 0, 233, 0, 0, 0, 0, 0, 0, 0], 1], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 8, 0, 1, 1, 15, 0, 3], 'malformed'], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 8, 0, 0, 0, 4, 0, 18, 1, 3, 0, 1, 0, 0, 0, 6, 0, 0, 0, 15, 1, 3, 0, 1, 0, 0, 0, 147, 0, 0, 0, 16, 1, 3, 0, 1, 0, 0, 0, 88, 0, 0, 0, 26, 1, 3, 0, 1, 0, 0, 0, 151, 1, 0, 0, 0, 0, 0, 0], 6], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 18, 1, 3, 0, 2, 0, 0, 0, 8, 0, 0, 0, 26, 1, 3, 0, 1, 0, 0, 0, 6, 1, 0, 0, 15, 1, 3, 0, 1, 0, 0, 0, 125, 1, 0, 0, 16, 1, 3, 0, 1, 0, 0, 0, 225, 1, 0, 0, 18, 1, 3, 0, 1, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0], 5], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 10, 0, 0, 0, 4, 1, 18, 0, 4, 0, 0, 0, 1, 0, 0, 0, 8, 1, 15, 0, 3, 0, 0, 0, 1, 1, 166, 0, 0, 1, 15, 0, 3, 0, 0, 0, 1, 0, 155, 0, 0, 1, 18, 0, 3, 0, 0, 0, 1, 0, 0, 0, 0], 1]], [[[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 10, 0, 0, 0, 0, 0, 2, 0, 26, 1, 3, 0, 1, 0, 0, 0, 4, 0, 0, 0, 16, 1, 3, 0, 1, 0, 0, 0, 180, 1, 0, 0], 1], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 10, 0, 0, 0, 3, 1, 16, 0, 3, 0, 0, 0, 1, 0, 38, 0, 0, 1, 15, 0, 3, 0, 0, 0, 1, 1, 166, 0, 0, 1, 26, 0, 3, 0, 0, 0, 1], 'malformed'], [[69, 120, 105, 102, 0, 0, 73, 73, 0, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 18, 1, 4, 0, 1, 0, 0, 0, 3, 0, 0, 0, 16, 1, 3, 0, 1, 0, 0, 0, 241, 0, 0, 0, 0, 0, 0, 0], 'malformed'], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 15, 1, 3, 0, 1, 0, 0, 0, 51, 1, 0, 0, 18, 1, 3, 0, 1, 0, 0, 0, 8, 0, 0, 0, 16, 1, 3, 0, 1, 0, 0, 0, 55], 8], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 8, 0, 0, 0, 2, 0, 15, 1, 3, 0, 1, 0, 0, 0, 215, 1, 0, 0, 18, 1, 3, 0, 1, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0], 7], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 8, 0, 4, 1, 18, 0, 3, 0, 0, 0, 2, 0, 8, 0, 0, 1, 15, 0, 3, 0, 0, 0, 1, 0, 173, 0, 0, 1, 16, 0, 3, 0, 0, 0, 1, 1, 83, 0, 0, 1, 15, 0, 3, 0, 0, 0, 1, 1, 181, 0, 0, 0, 0, 0, 0], 1], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 8, 0, 3, 1, 16, 0, 3, 0, 0, 0, 1, 0, 196, 0, 0, 1, 18, 0, 3, 0, 0, 0, 1, 0, 1, 0, 0, 1, 16, 0, 3, 0, 0, 0, 1, 0, 141, 0, 0, 0, 0, 0, 0], 1], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 10, 0, 0, 0, 0, 0, 2, 0, 26, 1, 3, 0, 1, 0, 0, 0, 14, 1, 0, 0, 18, 1, 3, 0, 1, 0, 0, 0, 5, 0, 0, 0], 5]]]
labels = ["regression: entry bounds check", "repair trap", "combined fault", "control", "control", "boundary", "boundary", "control"]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("%s %d" % (labels[i % len(labels)], i), solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: entry bounds check 0 | malformed | 1 | Failed |
| repair trap 1 | malformed | malformed | Passed |
| combined fault 2 | malformed | malformed | Passed |
| control 3 | malformed | malformed | Passed |
| control 4 | 1 | 1 | Passed |
| boundary 5 | 1 | 1 | Passed |
| boundary 6 | malformed | malformed | Passed |
| control 7 | malformed | 5 | Failed |
SHA-256 / 85a988435f863f9ba0d3b5a26e8c8619b420efd451b4d5e60a001db90d65c174
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(data):
b = data
if len(b) < 14 or b[:6] != [69, 120, 105, 102, 0, 0]:
return 'malformed'
t = b[6:]
if t[:2] == [73, 73]:
le = True
elif t[:2] == [77, 77]:
le = False
else:
return 'malformed'
def u16(o):
if o + 2 > len(t):
return None
return t[o] | (t[o + 1] << 8) if le else (t[o] << 8) | t[o + 1]
def u32(o):
if o + 4 > len(t):
return None
v = t[o:o + 4]
if le:
v = v[::-1]
return (v[0] << 24) | (v[1] << 16) | (v[2] << 8) | v[3]
if u16(2) != 42:
return 'malformed'
ifd = u32(4)
count = u16(ifd)
if count is None:
return 'malformed'
for i in range(count):
e = ifd + 2 + 12 * i
if e + 8 > len(t):
return 'malformed'
tag = u16(e)
typ = u16(e + 2)
cnt = u32(e + 4)
if tag == 0x0112 and typ == 3 and cnt == 1:
val = u16(e + 8)
return val if 1 <= val <= 8 else 1
return 1
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 8, 0, 3, 1, 15, 0, 3, 0, 0, 0, 1, 0, 7, 0, 0, 1, 26, 0, 3, 0, 0, 0, 1, 0, 114, 0, 0, 1, 18, 0, 3, 0, 0, 0, 1, 0, 0, 0, 0], 1], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 8, 0, 0, 0, 3, 0, 15, 1, 3, 0, 1, 0, 0, 0, 136, 0, 0, 0, 16, 1, 3, 0, 1, 0, 0, 0, 192, 1, 0, 0, 18, 1, 3, 0, 1, 0, 0, 0, 7, 0, 0], 'malformed'], [[69, 120, 105, 102, 0, 0, 73, 73, 0, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 26, 1, 3, 0, 1, 0, 0, 0, 126, 1, 0], 'malformed'], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 43, 0, 0, 0, 8, 0, 1, 1, 18, 0, 3, 0, 0, 0, 1, 0, 4, 0, 0, 0, 0, 0, 0], 'malformed'], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 10, 0, 0, 0, 0, 0, 2, 0, 15, 1, 3, 0, 1, 0, 0, 0, 73, 0, 0, 0, 26, 1, 3, 0, 1, 0, 0, 0, 37, 0, 0, 0, 0, 0, 0, 0], 1], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 8, 0, 0, 0, 2, 0, 16, 1, 3, 0, 1, 0, 0, 0, 247, 0, 0, 0, 15, 1, 3, 0, 1, 0, 0, 0, 124, 1, 0, 0, 0, 0, 0, 0], 1], [[69, 120, 105, 102, 0, 255, 77, 77, 0, 42, 0, 0, 0, 10, 0, 0, 0, 1, 1, 18, 0, 3, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], 'malformed'], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 8, 0, 0, 0, 2, 0, 15, 1, 3, 0, 1, 0, 0, 0, 137, 1, 0, 0, 18, 1, 3, 0, 1, 0, 0, 0, 5, 0, 0, 0], 5]], [[[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 8, 0, 0, 0, 2, 0, 16, 1, 3, 0, 1, 0, 0, 0, 87, 0, 0, 0, 26, 1, 3, 0, 1, 0, 0, 0, 107, 0, 0, 0], 1], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 8, 0, 4, 1, 18, 0, 3, 0, 0, 0, 2, 0, 6, 0, 0, 1, 15, 0, 3, 0, 0, 0, 1, 0, 31, 0, 0, 1, 16, 0, 3, 0, 0, 0, 1, 0, 202, 0, 0, 1, 16, 0, 3, 0, 0, 0, 1], 'malformed'], [[69, 120, 105, 102, 0, 255, 77, 77, 0, 42, 0, 0, 0, 14, 0, 0, 0, 0, 0, 0, 0, 2, 1, 18, 0, 3, 0, 0, 0, 1, 0, 1, 0, 0, 1, 26, 0, 3, 0, 0, 0, 1, 0, 46, 0, 0, 0, 0, 0, 0], 'malformed'], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 8, 0, 3, 1, 15, 0, 3, 0, 0, 0, 1, 1, 96, 0, 0, 1, 18, 0, 3, 0, 0, 0, 1, 0, 0, 0, 0, 1, 15, 0, 3, 0, 0, 0, 1, 1, 150], 1], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 10, 0, 0, 0, 0, 0, 3, 0, 26, 1, 3, 0, 1, 0, 0, 0, 115, 1, 0, 0, 16, 1, 3, 0, 1, 0, 0, 0, 111, 0, 0, 0, 18, 1, 3, 0, 1, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0], 8], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 10, 0, 0, 0, 5, 1, 18, 0, 4, 0, 0, 0, 2, 0, 0, 0, 8, 1, 26, 0, 3, 0, 0, 0, 1, 1, 15, 0, 0, 1, 15, 0, 3, 0, 0, 0, 1, 0, 190, 0, 0, 1, 18, 0, 3, 0, 0, 0, 1, 0, 6, 0, 0, 1, 15, 0, 3, 0, 0, 0, 1, 1, 77, 0, 0, 0, 0, 0, 0], 6], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 8, 0, 0, 0, 1, 0, 18, 1, 3, 0, 1, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0], 4], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 10, 0, 0, 0, 0, 0, 2, 0, 26, 1, 3, 0, 1, 0, 0, 0, 30, 0, 0, 0, 18, 1, 3, 0, 1, 0, 0, 0, 2, 0, 0, 0], 2]], [[[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 8, 0, 0, 0, 3, 0, 26, 1, 3, 0, 1, 0, 0, 0, 114, 1, 0, 0, 16, 1, 3, 0, 1, 0, 0, 0, 148, 1, 0, 0, 16, 1, 3, 0, 1, 0, 0, 0, 197, 0, 0, 0], 1], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 10, 0, 0, 0, 0, 0, 1, 0, 18, 1, 3, 0, 1, 0, 0, 0, 4, 0], 'malformed'], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 8, 0, 4, 1, 18, 0, 3, 0, 0, 0, 1, 0, 9, 0, 0, 1, 26, 0, 3, 0, 0, 0, 1, 1, 115, 0, 0, 1, 16, 0, 3, 0, 0, 0, 1, 1, 244, 0, 0, 1, 15, 0, 3, 0, 0, 0, 1, 1, 186, 0, 0, 0, 0, 0, 0], 1], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 1], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 18, 1, 3, 0, 1, 0, 0, 0, 8, 0, 0, 0, 15, 1, 3, 0, 1, 0, 0, 0, 202, 0, 0, 0, 15, 1, 3, 0, 1], 8], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 8, 0, 4, 1, 18, 0, 3, 0, 0, 0, 2, 0, 8, 0, 0, 1, 15, 0, 3, 0, 0, 0, 1, 0, 242, 0, 0, 1, 18, 0, 3, 0, 0, 0, 1, 0, 8, 0, 0, 1, 16, 0, 3, 0, 0, 0, 1, 1, 214, 0, 0, 0, 0, 0, 0], 8], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 10, 0, 0, 0, 4, 1, 18, 0, 3, 0, 0, 0, 2, 0, 3, 0, 0, 1, 18, 0, 3, 0, 0, 0, 1, 0, 6, 0, 0, 1, 15, 0, 3, 0, 0, 0, 1, 0, 195, 0, 0, 1, 26, 0, 3, 0, 0, 0, 1, 0, 238, 0, 0, 0, 0, 0, 0], 6], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 18, 1, 4, 0, 2, 0, 0, 0, 8, 0, 0, 0, 16, 1, 3, 0, 1, 0, 0, 0, 133, 1, 0, 0], 1]], [[[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 8, 0, 3, 1, 26, 0, 3, 0, 0, 0, 1, 0, 24, 0, 0, 1, 26, 0, 3, 0, 0, 0, 1, 0, 40, 0, 0, 1, 15, 0, 3, 0, 0, 0, 1, 1, 31, 0, 0], 1], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 8, 0, 3, 1, 16, 0, 3, 0, 0, 0, 1, 1, 163, 0, 0, 1, 26, 0, 3, 0, 0, 0, 1, 1, 29, 0, 0, 1, 15, 0, 3, 0, 0, 0, 1, 0, 18], 'malformed'], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 0, 0, 0, 0, 14, 0, 0, 0, 0, 0, 0, 0, 3, 1, 26, 0, 3, 0, 0, 0, 1, 1, 79, 0, 0, 1, 16, 0, 3, 0, 0, 0, 1, 1, 177, 0, 0, 1, 26, 0, 3, 0, 0], 'malformed'], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 8, 0, 0, 0, 3, 0, 26, 1, 3, 0, 1, 0, 0, 0, 17, 0, 0, 0, 15, 1, 3, 0, 1, 0, 0, 0, 37, 1, 0, 0, 15, 1, 3, 0, 1, 0, 0, 0, 233, 0, 0, 0, 0, 0, 0, 0], 1], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 8, 0, 1, 1, 15, 0, 3], 'malformed'], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 8, 0, 0, 0, 4, 0, 18, 1, 3, 0, 1, 0, 0, 0, 6, 0, 0, 0, 15, 1, 3, 0, 1, 0, 0, 0, 147, 0, 0, 0, 16, 1, 3, 0, 1, 0, 0, 0, 88, 0, 0, 0, 26, 1, 3, 0, 1, 0, 0, 0, 151, 1, 0, 0, 0, 0, 0, 0], 6], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 18, 1, 3, 0, 2, 0, 0, 0, 8, 0, 0, 0, 26, 1, 3, 0, 1, 0, 0, 0, 6, 1, 0, 0, 15, 1, 3, 0, 1, 0, 0, 0, 125, 1, 0, 0, 16, 1, 3, 0, 1, 0, 0, 0, 225, 1, 0, 0, 18, 1, 3, 0, 1, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0], 5], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 10, 0, 0, 0, 4, 1, 18, 0, 4, 0, 0, 0, 1, 0, 0, 0, 8, 1, 15, 0, 3, 0, 0, 0, 1, 1, 166, 0, 0, 1, 15, 0, 3, 0, 0, 0, 1, 0, 155, 0, 0, 1, 18, 0, 3, 0, 0, 0, 1, 0, 0, 0, 0], 1]], [[[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 10, 0, 0, 0, 0, 0, 2, 0, 26, 1, 3, 0, 1, 0, 0, 0, 4, 0, 0, 0, 16, 1, 3, 0, 1, 0, 0, 0, 180, 1, 0, 0], 1], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 10, 0, 0, 0, 3, 1, 16, 0, 3, 0, 0, 0, 1, 0, 38, 0, 0, 1, 15, 0, 3, 0, 0, 0, 1, 1, 166, 0, 0, 1, 26, 0, 3, 0, 0, 0, 1], 'malformed'], [[69, 120, 105, 102, 0, 0, 73, 73, 0, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 18, 1, 4, 0, 1, 0, 0, 0, 3, 0, 0, 0, 16, 1, 3, 0, 1, 0, 0, 0, 241, 0, 0, 0, 0, 0, 0, 0], 'malformed'], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 15, 1, 3, 0, 1, 0, 0, 0, 51, 1, 0, 0, 18, 1, 3, 0, 1, 0, 0, 0, 8, 0, 0, 0, 16, 1, 3, 0, 1, 0, 0, 0, 55], 8], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 8, 0, 0, 0, 2, 0, 15, 1, 3, 0, 1, 0, 0, 0, 215, 1, 0, 0, 18, 1, 3, 0, 1, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0], 7], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 8, 0, 4, 1, 18, 0, 3, 0, 0, 0, 2, 0, 8, 0, 0, 1, 15, 0, 3, 0, 0, 0, 1, 0, 173, 0, 0, 1, 16, 0, 3, 0, 0, 0, 1, 1, 83, 0, 0, 1, 15, 0, 3, 0, 0, 0, 1, 1, 181, 0, 0, 0, 0, 0, 0], 1], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 8, 0, 3, 1, 16, 0, 3, 0, 0, 0, 1, 0, 196, 0, 0, 1, 18, 0, 3, 0, 0, 0, 1, 0, 1, 0, 0, 1, 16, 0, 3, 0, 0, 0, 1, 0, 141, 0, 0, 0, 0, 0, 0], 1], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 10, 0, 0, 0, 0, 0, 2, 0, 26, 1, 3, 0, 1, 0, 0, 0, 14, 1, 0, 0, 18, 1, 3, 0, 1, 0, 0, 0, 5, 0, 0, 0], 5]]]
labels = ["regression: entry bounds check", "repair trap", "combined fault", "control", "control", "boundary", "boundary", "control"]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("%s %d" % (labels[i % len(labels)], i), solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: entry bounds check 0 | 1 | 1 | Passed |
| repair trap 1 | 7 | malformed | Failed |
| combined fault 2 | malformed | malformed | Passed |
| control 3 | malformed | malformed | Passed |
| control 4 | 1 | 1 | Passed |
| boundary 5 | 1 | 1 | Passed |
| boundary 6 | malformed | malformed | Passed |
| control 7 | 5 | 5 | Passed |
SHA-256 / d5a55484a25654d873d08e3bdc631d728e2a22195c17c1a304452dc49795af0d
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(data):
b = data
if len(b) < 14 or b[:6] != [69, 120, 105, 102, 0, 0]:
return 'malformed'
t = b[6:]
if t[:2] == [73, 73]:
le = True
elif t[:2] == [77, 77]:
le = False
else:
return 'malformed'
def u16(o):
if o + 2 > len(t):
return None
return t[o] | (t[o + 1] << 8) if le else (t[o] << 8) | t[o + 1]
def u32(o):
if o + 4 > len(t):
return None
v = t[o:o + 4]
if le:
v = v[::-1]
return (v[0] << 24) | (v[1] << 16) | (v[2] << 8) | v[3]
if u16(2) != 42:
return 'malformed'
ifd = u32(4)
count = u16(ifd)
if count is None:
return 'malformed'
for i in range(count):
e = ifd + 2 + 12 * i
if e + 12 > len(t):
return 'malformed'
tag = u16(e)
typ = u16(e + 2)
cnt = u32(e + 4)
if tag == 0x0112 and typ == 3 and cnt == 1:
val = u16(e + 8)
return val if 1 <= val <= 8 else 1
return 1
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 8, 0, 3, 1, 15, 0, 3, 0, 0, 0, 1, 0, 7, 0, 0, 1, 26, 0, 3, 0, 0, 0, 1, 0, 114, 0, 0, 1, 18, 0, 3, 0, 0, 0, 1, 0, 0, 0, 0], 1], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 8, 0, 0, 0, 3, 0, 15, 1, 3, 0, 1, 0, 0, 0, 136, 0, 0, 0, 16, 1, 3, 0, 1, 0, 0, 0, 192, 1, 0, 0, 18, 1, 3, 0, 1, 0, 0, 0, 7, 0, 0], 'malformed'], [[69, 120, 105, 102, 0, 0, 73, 73, 0, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 26, 1, 3, 0, 1, 0, 0, 0, 126, 1, 0], 'malformed'], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 43, 0, 0, 0, 8, 0, 1, 1, 18, 0, 3, 0, 0, 0, 1, 0, 4, 0, 0, 0, 0, 0, 0], 'malformed'], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 10, 0, 0, 0, 0, 0, 2, 0, 15, 1, 3, 0, 1, 0, 0, 0, 73, 0, 0, 0, 26, 1, 3, 0, 1, 0, 0, 0, 37, 0, 0, 0, 0, 0, 0, 0], 1], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 8, 0, 0, 0, 2, 0, 16, 1, 3, 0, 1, 0, 0, 0, 247, 0, 0, 0, 15, 1, 3, 0, 1, 0, 0, 0, 124, 1, 0, 0, 0, 0, 0, 0], 1], [[69, 120, 105, 102, 0, 255, 77, 77, 0, 42, 0, 0, 0, 10, 0, 0, 0, 1, 1, 18, 0, 3, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], 'malformed'], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 8, 0, 0, 0, 2, 0, 15, 1, 3, 0, 1, 0, 0, 0, 137, 1, 0, 0, 18, 1, 3, 0, 1, 0, 0, 0, 5, 0, 0, 0], 5]], [[[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 8, 0, 0, 0, 2, 0, 16, 1, 3, 0, 1, 0, 0, 0, 87, 0, 0, 0, 26, 1, 3, 0, 1, 0, 0, 0, 107, 0, 0, 0], 1], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 8, 0, 4, 1, 18, 0, 3, 0, 0, 0, 2, 0, 6, 0, 0, 1, 15, 0, 3, 0, 0, 0, 1, 0, 31, 0, 0, 1, 16, 0, 3, 0, 0, 0, 1, 0, 202, 0, 0, 1, 16, 0, 3, 0, 0, 0, 1], 'malformed'], [[69, 120, 105, 102, 0, 255, 77, 77, 0, 42, 0, 0, 0, 14, 0, 0, 0, 0, 0, 0, 0, 2, 1, 18, 0, 3, 0, 0, 0, 1, 0, 1, 0, 0, 1, 26, 0, 3, 0, 0, 0, 1, 0, 46, 0, 0, 0, 0, 0, 0], 'malformed'], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 8, 0, 3, 1, 15, 0, 3, 0, 0, 0, 1, 1, 96, 0, 0, 1, 18, 0, 3, 0, 0, 0, 1, 0, 0, 0, 0, 1, 15, 0, 3, 0, 0, 0, 1, 1, 150], 1], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 10, 0, 0, 0, 0, 0, 3, 0, 26, 1, 3, 0, 1, 0, 0, 0, 115, 1, 0, 0, 16, 1, 3, 0, 1, 0, 0, 0, 111, 0, 0, 0, 18, 1, 3, 0, 1, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0], 8], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 10, 0, 0, 0, 5, 1, 18, 0, 4, 0, 0, 0, 2, 0, 0, 0, 8, 1, 26, 0, 3, 0, 0, 0, 1, 1, 15, 0, 0, 1, 15, 0, 3, 0, 0, 0, 1, 0, 190, 0, 0, 1, 18, 0, 3, 0, 0, 0, 1, 0, 6, 0, 0, 1, 15, 0, 3, 0, 0, 0, 1, 1, 77, 0, 0, 0, 0, 0, 0], 6], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 8, 0, 0, 0, 1, 0, 18, 1, 3, 0, 1, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0], 4], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 10, 0, 0, 0, 0, 0, 2, 0, 26, 1, 3, 0, 1, 0, 0, 0, 30, 0, 0, 0, 18, 1, 3, 0, 1, 0, 0, 0, 2, 0, 0, 0], 2]], [[[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 8, 0, 0, 0, 3, 0, 26, 1, 3, 0, 1, 0, 0, 0, 114, 1, 0, 0, 16, 1, 3, 0, 1, 0, 0, 0, 148, 1, 0, 0, 16, 1, 3, 0, 1, 0, 0, 0, 197, 0, 0, 0], 1], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 10, 0, 0, 0, 0, 0, 1, 0, 18, 1, 3, 0, 1, 0, 0, 0, 4, 0], 'malformed'], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 8, 0, 4, 1, 18, 0, 3, 0, 0, 0, 1, 0, 9, 0, 0, 1, 26, 0, 3, 0, 0, 0, 1, 1, 115, 0, 0, 1, 16, 0, 3, 0, 0, 0, 1, 1, 244, 0, 0, 1, 15, 0, 3, 0, 0, 0, 1, 1, 186, 0, 0, 0, 0, 0, 0], 1], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 1], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 18, 1, 3, 0, 1, 0, 0, 0, 8, 0, 0, 0, 15, 1, 3, 0, 1, 0, 0, 0, 202, 0, 0, 0, 15, 1, 3, 0, 1], 8], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 8, 0, 4, 1, 18, 0, 3, 0, 0, 0, 2, 0, 8, 0, 0, 1, 15, 0, 3, 0, 0, 0, 1, 0, 242, 0, 0, 1, 18, 0, 3, 0, 0, 0, 1, 0, 8, 0, 0, 1, 16, 0, 3, 0, 0, 0, 1, 1, 214, 0, 0, 0, 0, 0, 0], 8], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 10, 0, 0, 0, 4, 1, 18, 0, 3, 0, 0, 0, 2, 0, 3, 0, 0, 1, 18, 0, 3, 0, 0, 0, 1, 0, 6, 0, 0, 1, 15, 0, 3, 0, 0, 0, 1, 0, 195, 0, 0, 1, 26, 0, 3, 0, 0, 0, 1, 0, 238, 0, 0, 0, 0, 0, 0], 6], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 18, 1, 4, 0, 2, 0, 0, 0, 8, 0, 0, 0, 16, 1, 3, 0, 1, 0, 0, 0, 133, 1, 0, 0], 1]], [[[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 8, 0, 3, 1, 26, 0, 3, 0, 0, 0, 1, 0, 24, 0, 0, 1, 26, 0, 3, 0, 0, 0, 1, 0, 40, 0, 0, 1, 15, 0, 3, 0, 0, 0, 1, 1, 31, 0, 0], 1], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 8, 0, 3, 1, 16, 0, 3, 0, 0, 0, 1, 1, 163, 0, 0, 1, 26, 0, 3, 0, 0, 0, 1, 1, 29, 0, 0, 1, 15, 0, 3, 0, 0, 0, 1, 0, 18], 'malformed'], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 0, 0, 0, 0, 14, 0, 0, 0, 0, 0, 0, 0, 3, 1, 26, 0, 3, 0, 0, 0, 1, 1, 79, 0, 0, 1, 16, 0, 3, 0, 0, 0, 1, 1, 177, 0, 0, 1, 26, 0, 3, 0, 0], 'malformed'], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 8, 0, 0, 0, 3, 0, 26, 1, 3, 0, 1, 0, 0, 0, 17, 0, 0, 0, 15, 1, 3, 0, 1, 0, 0, 0, 37, 1, 0, 0, 15, 1, 3, 0, 1, 0, 0, 0, 233, 0, 0, 0, 0, 0, 0, 0], 1], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 8, 0, 1, 1, 15, 0, 3], 'malformed'], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 8, 0, 0, 0, 4, 0, 18, 1, 3, 0, 1, 0, 0, 0, 6, 0, 0, 0, 15, 1, 3, 0, 1, 0, 0, 0, 147, 0, 0, 0, 16, 1, 3, 0, 1, 0, 0, 0, 88, 0, 0, 0, 26, 1, 3, 0, 1, 0, 0, 0, 151, 1, 0, 0, 0, 0, 0, 0], 6], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 18, 1, 3, 0, 2, 0, 0, 0, 8, 0, 0, 0, 26, 1, 3, 0, 1, 0, 0, 0, 6, 1, 0, 0, 15, 1, 3, 0, 1, 0, 0, 0, 125, 1, 0, 0, 16, 1, 3, 0, 1, 0, 0, 0, 225, 1, 0, 0, 18, 1, 3, 0, 1, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0], 5], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 10, 0, 0, 0, 4, 1, 18, 0, 4, 0, 0, 0, 1, 0, 0, 0, 8, 1, 15, 0, 3, 0, 0, 0, 1, 1, 166, 0, 0, 1, 15, 0, 3, 0, 0, 0, 1, 0, 155, 0, 0, 1, 18, 0, 3, 0, 0, 0, 1, 0, 0, 0, 0], 1]], [[[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 10, 0, 0, 0, 0, 0, 2, 0, 26, 1, 3, 0, 1, 0, 0, 0, 4, 0, 0, 0, 16, 1, 3, 0, 1, 0, 0, 0, 180, 1, 0, 0], 1], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 10, 0, 0, 0, 3, 1, 16, 0, 3, 0, 0, 0, 1, 0, 38, 0, 0, 1, 15, 0, 3, 0, 0, 0, 1, 1, 166, 0, 0, 1, 26, 0, 3, 0, 0, 0, 1], 'malformed'], [[69, 120, 105, 102, 0, 0, 73, 73, 0, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 18, 1, 4, 0, 1, 0, 0, 0, 3, 0, 0, 0, 16, 1, 3, 0, 1, 0, 0, 0, 241, 0, 0, 0, 0, 0, 0, 0], 'malformed'], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 15, 1, 3, 0, 1, 0, 0, 0, 51, 1, 0, 0, 18, 1, 3, 0, 1, 0, 0, 0, 8, 0, 0, 0, 16, 1, 3, 0, 1, 0, 0, 0, 55], 8], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 8, 0, 0, 0, 2, 0, 15, 1, 3, 0, 1, 0, 0, 0, 215, 1, 0, 0, 18, 1, 3, 0, 1, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0], 7], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 8, 0, 4, 1, 18, 0, 3, 0, 0, 0, 2, 0, 8, 0, 0, 1, 15, 0, 3, 0, 0, 0, 1, 0, 173, 0, 0, 1, 16, 0, 3, 0, 0, 0, 1, 1, 83, 0, 0, 1, 15, 0, 3, 0, 0, 0, 1, 1, 181, 0, 0, 0, 0, 0, 0], 1], [[69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 8, 0, 3, 1, 16, 0, 3, 0, 0, 0, 1, 0, 196, 0, 0, 1, 18, 0, 3, 0, 0, 0, 1, 0, 1, 0, 0, 1, 16, 0, 3, 0, 0, 0, 1, 0, 141, 0, 0, 0, 0, 0, 0], 1], [[69, 120, 105, 102, 0, 0, 73, 73, 42, 0, 10, 0, 0, 0, 0, 0, 2, 0, 26, 1, 3, 0, 1, 0, 0, 0, 14, 1, 0, 0, 18, 1, 3, 0, 1, 0, 0, 0, 5, 0, 0, 0], 5]]]
labels = ["regression: entry bounds check", "repair trap", "combined fault", "control", "control", "boundary", "boundary", "control"]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("%s %d" % (labels[i % len(labels)], i), solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: entry bounds check 0 | 1 | 1 | Passed |
| repair trap 1 | malformed | malformed | Passed |
| combined fault 2 | malformed | malformed | Passed |
| control 3 | malformed | malformed | Passed |
| control 4 | 1 | 1 | Passed |
| boundary 5 | 1 | 1 | Passed |
| boundary 6 | malformed | malformed | Passed |
| control 7 | 5 | 5 | Passed |
SHA-256 / d6120096760e7ad5ff5e48b6b53178ae3fb443801fe1728ed0a0120b96c0d70c
Verification & scope
A deterministic bounded teaching model with a stipulated contract; it makes no claim of conformance to any published specification. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:49:39.883245+00:00.
Case digest / 17194c7450933415e23ddd4ae10532d5cf2b83fd514e99666c4f6db31e5b76b3