[EventHub][ServiceBus] Fix pyAMQP decode of performatives with omitted trailing null fields#47660
Draft
j7nw4r wants to merge 1 commit into
Draft
[EventHub][ServiceBus] Fix pyAMQP decode of performatives with omitted trailing null fields#47660j7nw4r wants to merge 1 commit into
j7nw4r wants to merge 1 commit into
Conversation
AMQP 1.0 section 1.4 lets a sender omit trailing null fields, so an incoming performative described-list can be shorter than the full field count. The pyAMQP decoder built the field list from the wire count, and consumers then accessed fixed indices (frame[9], OpenFrame(*frame)), raising IndexError/TypeError on a short list. decode_frame now pads the decoded list up to the performative's full field count, so omitted trailing fields read back as None. Applied to both the Event Hubs and Service Bus vendored copies, with regression tests and changelog entries.
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.
Summary
The pyAMQP transport crashes when decoding an AMQP performative whose trailing null fields were omitted by the sender. The decoded performative list is now padded to its full field count so positional field access and namedtuple unpacking remain safe, with omitted trailing fields reading back as null.
Motivation
AMQP 1.0 section 1.4 permits a sender to omit the trailing null fields of a described list, so an incoming performative can arrive shorter than its full field count. The decoder in
_decode.pybuilt the field list from the element count on the wire, and downstream consumers then read fixed positions (for exampleframe[9]for Open properties, andOpenFrame(*frame)namedtuple unpacking). On a short list this raisedIndexErrororTypeError. This is the receiver side of Azure/amqpnetlite#645: a spec-compliant sender that omits trailing nulls triggers the crash, while brokers and other AMQP stacks that bound decoding by the wire count are unaffected.Changes
decode_frameup to the performative's full field count, derived from each performative's_definitionand excluding the transfer payload slot, before any positional access or namedtuple unpacking, so omitted trailing fields read back asNone._pyamqpcopies.Test plan
pytest tests/pyamqp_tests/unittest/test_decode.py, 15 passed.pytest tests/unittests/test_pyamqp_decode.py, 11 passed.