bug: struct decode silently drops earlier sections when a section name repeats, unlike map decode #16
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
In
encoding/systemd/marshal_decode.go,decodeFileNode(~lines 63–71), the section lookup is built with:This overwrites any earlier section with the same name, so only the last occurrence's assignments are ever applied to the destination struct.
decodeFileToMap(the map-decode path), by contrast, merges assignments across all sections sharing a name into the same destination map. The two decode paths silently disagree on the same input, and the struct path silently loses data with no error.Reproduction
Recommended fix
Make
decodeFileNodemerge assignments from all sections sharing a name (e.g. accumulate a[]*AssignNodeper clean name, or calldecodeSectionNodeonce per matching section against the samefieldValinstead of looking up a single winner) so struct decoding matches the map decoding semantics.