Skip to content

fix: write the 0 holder id for inline registryEntryHolder entries - #1523

Open
u9g wants to merge 1 commit into
PrismarineJS:masterfrom
u9g:fix/registry-entry-holder-inline-write
Open

fix: write the 0 holder id for inline registryEntryHolder entries#1523
u9g wants to merge 1 commit into
PrismarineJS:masterfrom
u9g:fix/registry-entry-holder-inline-write

Conversation

@u9g

@u9g u9g commented Sep 6, 2026

Copy link
Copy Markdown
Member

Constraints on the compiled registryEntryHolder writer:

  • An inline entry is written as varint 0 followed by the entry; every byte the writer advances over is written.
  • A registry entry is written as varint id + 1.
  • sizeOf and write agree on the length in both cases, and the reader parses either back to the same value.

Test (test/registryEntryHolderTest.js): a 1.21.4 Slot whose consumable component carries an inline sound is written into a 0xff-filled buffer; the holder id byte must be 0, the round trip must parse to the same value with the same size, and the registry case must encode id + 1. Fails on master, passes with the change.

The compiled writer for registryEntryHolder advanced the offset by one
byte for an inline (non-registry) entry without writing anything there,
so the holder id came out as whatever the unsafe buffer already held.
Any serverbound packet carrying such an entry was corrupt on the wire:
a 1.21.2+ client echoing an item ViaVersion gave a consumable component
with an inline sound (every sword on a ViaVersion proxy) in a
window_click sends a garbage holder id, and the backend drops the
connection ("Your connection to <server> encountered a problem").
sizeOf already counted the byte and the reader already expects 0.

Adds a test that writes into a 0xff-filled buffer, where a skipped byte
cannot pass by chance.
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