Repository navigation
picoparams: parse every SetParameters entry, refuse bad input - #26
Merged
Merged
Conversation
deserialize_ros_ParameterValue() returned straight after the scalar it was asked for, leaving string_value and the five array lengths unread, so the second Parameter of a SetParameters request was decoded from the middle of the first: it read as "Parameter not found". A set of x and z in one call lost z. All ten fields are now read (array contents are still not skipped, so array-typed values remain one-per-request). set_params_value() trusted the wire's parameter count, looping up to 2^32 times on the zenoh read task for a 12-byte request; reused the previous name when one failed to decode; skipped an unknown name's value, misaligning every later entry; and could act on a value cut short. It now stops at the first undecodable entry, reads each value before looking up its name, and writes the result count last, so a request cut short gets one result per entry it carried rather than the count it claimed. params_server_handler() computed request_size - 4 unchecked, so an empty request made a buffer that wrapped the address space; it now sends no reply. set_parameters_atomically replied with a bare CDR header, which clients fail to decode; it now refuses with a well-formed SetParametersResult. Signed-off-by: Richard Osterloh <richard.osterloh@gmail.com>
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.
picoparams.cmis-decodesSetParametersrequests with more than one entry, and trusts several wire-supplied lengths. Found while running a Pico-ROS parameter server againstrmw_zenoh_cppon ESP32 boards. Independent of #25 (different file), and merges cleanly with it in either order.Decode every entry of a
SetParametersrequestdeserialize_ros_ParameterValue()returned straight after the scalar it was asked for, leavingstring_valueand the five array lengths unread. The secondParameterwas therefore decoded from the middle of the first and came back as "Parameter not found": settingxandzin one call lostz. All ten fields are now read. Array contents are still not skipped, so array-typed values remain one per request.Refuse bad input in
set_params_value()It now stops at the first undecodable entry, reads each value before looking up its name, and writes the result count last. A request cut short gets one result per entry it actually carried, rather than the count it claimed.
params_server_handler()andset_parameters_atomicallyrequest_size - 4was computed unchecked, so an empty request produced a buffer length that wrapped the address space. It now sends no reply.set_parameters_atomicallyreplied with a bare CDR header, which clients fail to decode. It now refuses with a well-formedSetParametersResult.Well-formed single-parameter requests decode exactly as before.
Testing
CONFIG_PICOROS_PARAMS=y) on top ofb739fc7together with Bound string decoding, echo request identity in service replies, check z_malloc #25. No new warnings frompicoparams.c.picoparamsintest/yet; happy to add one if you'd like it covered the way Bound string decoding, echo request identity in service replies, check z_malloc #25 coverspicoserdes.🤖 Generated with Claude Code