Skip to content

Read the firmware version of a v6/v7 .md as the string it is - #61

Open
lgnap wants to merge 2 commits into
antoinevalentinHA:masterfrom
lgnap:fix/issue-17-firmware-version-parse
Open

lgnap wants to merge 2 commits into
antoinevalentinHA:masterfrom
lgnap:fix/issue-17-firmware-version-parse

Conversation

@lgnap

@lgnap lgnap commented Sep 11, 2026 •

Copy link
Copy Markdown

What

parseDeviceInfosMeta6to7 read the firmware version as one digit for the major, one skipped byte, one digit for the minor. On a real v7 card the field is a NUL-terminated ASCII string in a 6-byte slot — 3.2.3\0 (see FORMATS.md §2, #59) — so the patch level was dropped, and a firmware 3.10.x would have come back as 3.1, 10.0.x as 1.0. The version is not display-only: getFirmwareMajor() gates copyPack (firmware 2 or 3 only) and picks the V2 or V3 cipher and boot file, so this change touches the write path. Its safety rests on the 6-byte field being NUL-terminated after a short version on every device, which was measured on one card only, at 3.2.3. If a device carried something else after a short version, the old parser read it and the new one could refuse the device; the code comment says so.

The field is now read whole and split on dots. Major and minor keep their meaning; FsDeviceInfos exposes the full string, which StoryTellerService reports to the UI when present (the v1–3 path is untouched and still reports major.minor). The serial and the key material keep their offsets — the skip shrinks by what the read grew. A field without two components fails as a truncated .md already did. The two digit-only helpers this leaves unused are removed.

Tests

DeviceMetadataCharacterizationTest gains a fixture that writes the firmware field whole, and two tests: 3.2.3\0 → 3.2 / "3.2.3", 3.10.1 → 3.10, 10.0.0 → 10.0, 3.3 (the old fixture shape) → 3.3; and the serial / key / IV read from the same bytes as before. The existing tests, including the truncated-.md one, pass unchanged.

Locally: mvn … test → 332 run, 0 failures (39 FAT32 opt-in skips). git diff --exit-code clean.

Tracked in lgnap#17.

The field is a NUL-terminated ASCII string in a 6-byte slot — "3.2.3\0"
on a real v7 card (FORMATS.md §2). The parser took one digit for the
major, skipped a byte, took one digit for the minor: the patch level was
dropped, and a firmware "3.10.x" would have come back as 3.1, "10.0.x"
as 1.0. Harmless today, since the version is only displayed, and exactly
the kind of thing that bites the day code decides something from it.

The field is now read whole and split on dots; major and minor keep
their meaning, and FsDeviceInfos exposes the full string, which the
service reports to the UI when present. The serial and the key material
keep their offsets (the skip shrinks by what the read grew). A field
without two components fails as a truncated .md did before. The two
digit-only helpers this leaves unused are removed.

Closes #17
Following the review on antoinevalentinHA#68: the major is not display-only. copyPack
refuses anything but firmware 2 or 3 and picks the V2 or V3 cipher and
boot file from it, so reading the field up to its NUL changes the write
path. The comment now says so, and that the NUL termination was
measured on one card only, at 3.2.3.
@lgnap
lgnap force-pushed the fix/issue-17-firmware-version-parse branch from 7da08a6 to c30ee84 Compare November 19, 2026 15:22
@lgnap

lgnap commented Nov 19, 2026

Copy link
Copy Markdown
Author

Description and code comment corrected in c30ee84: the major gates copyPack and the cipher/boot file choice, and the NUL termination is stated as measured on one card at 3.2.3. I'll wait for your readings on 3.3 before anything else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant