From f6c4d774ad3ef089cbdc50886a0320e7d94fdde3 Mon Sep 17 00:00:00 2001 From: defnax <9952056+defnax@users.noreply.github.com> Date: Fri, 11 Sep 2026 16:26:33 +0200 Subject: [PATCH] Fix obsolete GXS status payloads appearing in broadcast chat Validate GXS chat transport payload types before processing them as chat messages. Older development builds accidentally sent contact status items through the chat subservice. These packets can remain in GXS store-and-forward storage and were force-cast to chat messages, causing binary status values to appear repeatedly in broadcast chat. Drop and acknowledge non-chat payloads received through the GXS chat subservice. Also release deserialized items when distant-chat initialization fails. --- src/chat/p3chatservice.cc | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/chat/p3chatservice.cc b/src/chat/p3chatservice.cc index e58532740..847739ade 100644 --- a/src/chat/p3chatservice.cc +++ b/src/chat/p3chatservice.cc @@ -1075,14 +1075,33 @@ bool p3ChatService::receiveGxsTransMail( const RsGxsId& authorId, const uint8_t* data, uint32_t dataSize ) { + uint32_t deserialisedSize = dataSize; + RsItem* deserialisedItem = _serializer->deserialise( + const_cast(data), &deserialisedSize ); + RsChatMsgItem* item = dynamic_cast(deserialisedItem); + + /* + * GXS transport subservice P3_CHAT_SERVICE is reserved for chat messages. + * Some development versions accidentally sent RsChatStatusItem here. Older + * receivers then force-cast that payload to RsChatMsgItem, displaying the + * binary status flag as a broadcast message. Such packets can remain in the + * store-and-forward network until the GXS transport retention period ends. + * Consume them, but never pass them to the normal chat processing path. + */ + if(!item) + { + std::cerr << __PRETTY_FUNCTION__ + << " (WW) dropping non-message payload received on the GXS chat subservice" + << std::endl; + delete deserialisedItem; + return true; + } + DistantChatPeerId pid; uint32_t error_code; if(initiateDistantChatConnexion( authorId, recipientId, pid, error_code, false )) { - RsChatMsgItem* item = static_cast( - _serializer->deserialise( - const_cast(data), &dataSize )); RsPeerId rd(p3GxsTunnelService::makeGxsTunnelId(authorId, recipientId)); item->PeerId(rd); handleRecvChatMsgItem(item); @@ -1090,6 +1109,8 @@ bool p3ChatService::receiveGxsTransMail( const RsGxsId& authorId, return true; } + delete item; + std::cerr << __PRETTY_FUNCTION__ << " (EE) failed initiating" << " distant chat connection error: "<< error_code << std::endl;