From 10ec52718db7ae82fe0bb4677e5650a83cf2e5ad Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Mon, 15 May 2017 15:00:21 +0200 Subject: [PATCH] Fix GxsTrans related serialization regressions --- libretroshare/src/chat/rschatitems.cc | 36 ++++++++++++------------ libretroshare/src/chat/rschatitems.h | 7 +++-- libretroshare/src/gxstrans/p3gxstrans.cc | 7 +++-- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/libretroshare/src/chat/rschatitems.cc b/libretroshare/src/chat/rschatitems.cc index f222d248b..88b835cc8 100644 --- a/libretroshare/src/chat/rschatitems.cc +++ b/libretroshare/src/chat/rschatitems.cc @@ -39,27 +39,27 @@ static const uint32_t RS_CHAT_SERIALIZER_FLAGS_NO_SIGNATURE = 0x0001; RsItem *RsChatSerialiser::create_item(uint16_t service_id,uint8_t item_sub_id) const { - if (service_id != RS_SERVICE_TYPE_CHAT) - return NULL; + if(service_id != RS_SERVICE_TYPE_CHAT) return NULL; switch(item_sub_id) { - case RS_PKT_SUBTYPE_DEFAULT: return new RsChatMsgItem() ; - case RS_PKT_SUBTYPE_PRIVATECHATMSG_CONFIG: return new RsPrivateChatMsgConfigItem() ; - case RS_PKT_SUBTYPE_CHAT_STATUS: return new RsChatStatusItem() ; - case RS_PKT_SUBTYPE_CHAT_AVATAR: return new RsChatAvatarItem() ; - case RS_PKT_SUBTYPE_CHAT_LOBBY_SIGNED_MSG: return new RsChatLobbyMsgItem() ; - case RS_PKT_SUBTYPE_CHAT_LOBBY_INVITE_DEPRECATED: return new RsChatLobbyInviteItem_Deprecated() ; // to be removed (deprecated since May 2017) - case RS_PKT_SUBTYPE_CHAT_LOBBY_INVITE: return new RsChatLobbyInviteItem() ; - case RS_PKT_SUBTYPE_CHAT_LOBBY_CHALLENGE: return new RsChatLobbyConnectChallengeItem() ; - case RS_PKT_SUBTYPE_CHAT_LOBBY_UNSUBSCRIBE: return new RsChatLobbyUnsubscribeItem() ; - case RS_PKT_SUBTYPE_CHAT_LOBBY_SIGNED_EVENT: return new RsChatLobbyEventItem() ; - case RS_PKT_SUBTYPE_CHAT_LOBBY_LIST_REQUEST: return new RsChatLobbyListRequestItem() ; - case RS_PKT_SUBTYPE_CHAT_LOBBY_LIST: return new RsChatLobbyListItem() ; - case RS_PKT_SUBTYPE_CHAT_LOBBY_CONFIG: return new RsChatLobbyConfigItem() ; - default: - std::cerr << "Unknown packet type in chat!" << std::endl ; - return NULL ; + case RS_PKT_SUBTYPE_DEFAULT: return new RsChatMsgItem(); + case RS_PKT_SUBTYPE_PRIVATECHATMSG_CONFIG: return new RsPrivateChatMsgConfigItem(); + case RS_PKT_SUBTYPE_CHAT_STATUS: return new RsChatStatusItem(); + case RS_PKT_SUBTYPE_CHAT_AVATAR: return new RsChatAvatarItem(); + case RS_PKT_SUBTYPE_CHAT_LOBBY_SIGNED_MSG: return new RsChatLobbyMsgItem(); + case RS_PKT_SUBTYPE_CHAT_LOBBY_INVITE: return new RsChatLobbyInviteItem(); + case RS_PKT_SUBTYPE_CHAT_LOBBY_INVITE_DEPRECATED: return new RsChatLobbyInviteItem_Deprecated(); // to be removed (deprecated since May 2017) + case RS_PKT_SUBTYPE_CHAT_LOBBY_CHALLENGE: return new RsChatLobbyConnectChallengeItem(); + case RS_PKT_SUBTYPE_CHAT_LOBBY_UNSUBSCRIBE: return new RsChatLobbyUnsubscribeItem(); + case RS_PKT_SUBTYPE_CHAT_LOBBY_SIGNED_EVENT: return new RsChatLobbyEventItem(); + case RS_PKT_SUBTYPE_CHAT_LOBBY_LIST_REQUEST: return new RsChatLobbyListRequestItem(); + case RS_PKT_SUBTYPE_CHAT_LOBBY_LIST: return new RsChatLobbyListItem(); + case RS_PKT_SUBTYPE_CHAT_LOBBY_CONFIG: return new RsChatLobbyConfigItem(); + case RS_PKT_SUBTYPE_OUTGOING_MAP: return new PrivateOugoingMapItem(); + default: + std::cerr << "Unknown packet type in chat!" << std::endl; + return NULL; } } diff --git a/libretroshare/src/chat/rschatitems.h b/libretroshare/src/chat/rschatitems.h index 9c5247fff..8ea4189f4 100644 --- a/libretroshare/src/chat/rschatitems.h +++ b/libretroshare/src/chat/rschatitems.h @@ -33,6 +33,7 @@ #include "rsitems/itempriorities.h" #include "rsitems/rsitem.h" #include "serialiser/rsserial.h" +#include "util/rsdeprecate.h" #include "serialiser/rstlvidset.h" #include "serialiser/rstlvfileitem.h" @@ -78,7 +79,9 @@ const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_SIGNED_MSG = 0x17 ; const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_SIGNED_EVENT = 0x18 ; const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_LIST = 0x19 ; +RS_DEPRECATED_FOR(RS_PKT_SUBTYPE_CHAT_LOBBY_INVITE) \ const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_INVITE_DEPRECATED = 0x1A ; // to be removed (deprecated since May 2017) + const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_INVITE = 0x1B ; const uint8_t RS_PKT_SUBTYPE_OUTGOING_MAP = 0x1C ; @@ -241,8 +244,8 @@ class RsChatLobbyConnectChallengeItem: public RsChatItem uint64_t challenge_code ; }; -// to be removed (deprecated since May 2017) -class RsChatLobbyInviteItem_Deprecated: public RsChatItem +/// @deprecated since May 2017, to be removed +class RsChatLobbyInviteItem_Deprecated : public RsChatItem { public: RsChatLobbyInviteItem_Deprecated() :RsChatItem(RS_PKT_SUBTYPE_CHAT_LOBBY_INVITE_DEPRECATED) {} diff --git a/libretroshare/src/gxstrans/p3gxstrans.cc b/libretroshare/src/gxstrans/p3gxstrans.cc index 4454bf6e1..d6082c3c3 100644 --- a/libretroshare/src/gxstrans/p3gxstrans.cc +++ b/libretroshare/src/gxstrans/p3gxstrans.cc @@ -478,11 +478,12 @@ bool p3GxsTrans::dispatchDecryptedMail( const RsGxsId& authorId, } GxsTransSubServices rsrvc = static_cast(csri); - uint32_t rcptsize = decrypted_data_size; + uint32_t rcptsize = decrypted_data_size - offset; RsNxsTransPresignedReceipt* receipt = static_cast( - RsGxsTransSerializer().deserialise( - const_cast(decrypted_data), &rcptsize ) ); + RsNxsSerialiser(RS_SERVICE_TYPE_GXS_TRANS).deserialise( + const_cast(&decrypted_data[offset]), &rcptsize )); + offset += rcptsize; if(!receipt) { std::cerr << "p3GxsTrans::dispatchDecryptedMail(...) (EE) fatal error "