Repository navigation
Cap client/hello nesting depth and size - #344
Merged
Merged
Conversation
1 task done
kahrendt
pushed a commit
that referenced
this pull request
Nov 5, 2026
<!-- Describe the change and why it is needed. --> A recognized message can carry a value outside its field's fixed range, such as `output_delay_ms` above 5000 in `client/state` or a controller `volume` of 101. Most fields don't say what the receiver does with one. This makes such a value a protocol error, and the receiver MUST close the connection. Only a broken implementation sends one, and closing matches how the spec treats other protocol errors. The rule only covers fixed ranges and length limits. Bounds relative to another value, like the visualizer `rate_max` or the player timing bounds, can be crossed by a message in flight, and the receiver often can't check them reliably. A field or message with its own rule keeps it: the server still ignores a `seek` outside 0 to `seek_max_ms`, a bad `client/init` is still an init failure, and the #344 `client/hello` caps keep their MAY close. This also removes handling the rule now covers: - truncating an over-long server `name` or `group_name` (from #339) and `client/pair-pending` `message` (from #194) - the SHOULD close for an artwork `channels` array longer than 4 - the player clamp rules for `output_delay_ms` and `min_buffer_ms`, since their 0-5000 field ranges already bind the sender It also adjusts text the rule would otherwise break: - an artwork client that truncates its `channels` array keeps at least one entry - metadata `track` states its range (at least 1), and `year` no longer says "YYYY format" - values inside ignored inactive-role objects are left unvalidated - sending a value outside a range or length limit an earlier revision defined needs negotiation, like a new field So plain text over its byte cap now closes the connection too, including a client `name` or `device_info` string over 64 bytes. - [x] I accept the [Contributor License Agreement](../blob/main/CONTRIBUTOR-LICENSE-AGREEMENT.md) for this contribution.
48 of 58 tasks
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.
client/hellois the only message whose content a server can't know in advance. It can carry support objects for application-specific roles, and it arrives before any role is negotiated, so a server that doesn't implement such a role still has to parse its object. A server that parses JSON with a fixed nesting limit closes the connection on a deeply nested object, even though unknown fields must be ignored. No server can meet the "large enough that no valid message it can receive exceeds it" from #322 forclient/helloeither, since it has no maximum size. When the server initiated the connection and playback is running, it reconnects after a drop, so an oversized hello turns into a reconnect loop.A
client/hellonow has at most 10 nesting levels and 16384 bytes, and servers must accept anything within those limits:client/hellotoday is 5 levels, for exampleplayer@v1_support.supported_formats. 10 is also ArduinoJson's default limit, and it counts levels the same way.client/hellowith every field at its maximum length and 82 formats is 6257 bytes. The formats cover 8 sample rates from 44.1 to 384 kHz, mono and stereo, every PCM and FLAC bit depth, and Opus. Only listing every channel count from 1 to 8 goes over, at 22223 bytes. A player over the cap drops its lowest priority formats.I first looked at size caps for every JSON message and length caps for the metadata strings. I left them out, since every other message is either defined by the spec or only sent for roles both sides implement, so the spec already controls how large and how deep it gets.
server/hellocan't carry application-specific support objects, so it needs no cap.sendspin-server-cpp already accepts both limits.