Skip to content

Fix GSSAPI PUB/SUB subscription corruption on reconnection#4848

Open
jake-scott wants to merge 1 commit intozeromq:masterfrom
jake-scott:fix-corrupt-re-subs
Open

Fix GSSAPI PUB/SUB subscription corruption on reconnection#4848
jake-scott wants to merge 1 commit intozeromq:masterfrom
jake-scott:fix-corrupt-re-subs

Conversation

@jake-scott
Copy link
Copy Markdown

Fixes #4847

Problem: When GSSAPI encryption is active, subscribe and cancel message flags (msg_t::subscribe = 12, msg_t::cancel = 16) were not preserved through the encode_message/decode_message round-trip.

encode_message() only captured the 'more' (bit 0) and 'command' (bit 1) flags in the wire flags byte. The subscribe flag occupies bits 2-3 (value 12) and cancel occupies bit 4 (value 16) — both outside the captured range, so they were silently zeroed on decoding.

After decode_message(), xpub_t::xread_activated() would not recognise the arriving message as a subscribe or cancel command, causing subscriptions to be silently dropped after reconnection (when xhiccuped() re-sends cached subscriptions through the GSSAPI path).

Solution: Encode the subscribe flag into wire bit 2 (0x04) and the cancel flag into wire bit 3 (0x08) in encode_message(), and restore them via set_flags(msg_t::subscribe) / set_flags(msg_t::cancel) in decode_message().

Problem: When GSSAPI encryption is active, subscribe and cancel message
flags (msg_t::subscribe = 12, msg_t::cancel = 16) were not preserved
through the encode_message/decode_message round-trip.

encode_message() only captured the 'more' (bit 0) and 'command' (bit 1)
flags in the wire flags byte. The subscribe flag occupies bits 2-3
(value 12) and cancel occupies bit 4 (value 16) — both outside the
captured range, so they were silently zeroed on decoding.

After decode_message(), xpub_t::xread_activated() would not recognise
the arriving message as a subscribe or cancel command, causing
subscriptions to be silently dropped after reconnection (when
xhiccuped() re-sends cached subscriptions through the GSSAPI path).

Solution: Encode the subscribe flag into wire bit 2 (0x04) and the
cancel flag into wire bit 3 (0x08) in encode_message(), and restore
them via set_flags(msg_t::subscribe) / set_flags(msg_t::cancel) in
decode_message().
@jake-scott
Copy link
Copy Markdown
Author

This patch appears to solve the issue (help from Claude)

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.

Corrupt subscriptions on re-connect when using encrypted GSSAPI

1 participant