Repository navigation
pdb: read the artist/album name offset from the row, not a hardcode - #50
Merged
Merged
Conversation
Serving a rekordbox USB mis-displayed some artists as hundreds of bytes of concatenated names (also the root cause the export sanitize fix masked). The reader assumed each artist/album name sat at a fixed row offset (10/12 for artists, 22/24 for albums), but the real format stores the name OFFSET in the row — a u8 for the near variant, a u16 for the far — and the string at that offset. A short ASCII name happens to sit at 10, so the hardcode worked for most rows; a longer or UTF-16 name sits further along, so the hardcode landed on padding, read a length-kind byte of 0x00 (neither ASCII nor UTF-16 flag set), and the decoder's fallback returned the entire rest of the string heap. Read row[9] (near) / row[10:12] (far) for artists and row[21] / row[22:24] for albums, matching the documented DeviceSQL layout. Also widen the artist/album id reads from u16 to the real u32. Safe for working libraries: where the old hardcode was right the name already sat at that offset, so the read-back offset equals the hardcode and the result is identical — validated across five real pdbs (a problem stick + four exports): every previously-correct artist unchanged, only the over-read rows fixed, zero regressions. TestParseArtistRowReadsNameOffset pins it with a short-ASCII and a UTF-16 row built to the real format.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Serving a rekordbox USB mis-displayed some artists as hundreds of bytes of concatenated names (the root cause the export-sanitize fixes in #49 masked). The pdb reader assumed each artist/album name sat at a fixed row offset (10/12 artists, 22/24 albums), but the real DeviceSQL format stores the name OFFSET in the row — a u8 for the near variant, a u16 for the far — and the string at that offset. A short ASCII name happens to sit at 10, so the hardcode worked for most rows; a longer or UTF-16 name (e.g. an artist with "ø") sits further along, so the hardcode landed on padding, read a length-kind byte of 0x00 (neither the ASCII nor UTF-16 flag set), and the decoder's fallback returned the whole rest of the string heap.
The reader now reads row[9] / row[10:12] for artists and row[21] / row[22:24] for albums, per the documented layout, and widens the id reads from u16 to the real u32.
Safe for working libraries: where the hardcode was right, the name already sat at that offset, so reading it back yields the identical result. Validated across five real pdbs (a problem stick plus four exports) — every previously-correct artist unchanged, only the over-read rows fixed, zero regressions. TestParseArtistRowReadsNameOffset pins it with short-ASCII and UTF-16 rows built to the real format.
Hardware testing
Checklist
go build ./...,go vet ./..., andgo test ./...passgofmt -l .is cleanGPL-3.0-or-later)