From 18e00b8e27272dde88c47560130298ddf8515474 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 18 Mar 2020 15:31:40 +0300 Subject: Jabber: more correct way of processing PGP packets --- protocols/JabberG/src/jabber_proto.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'protocols/JabberG/src') diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index a026b9f113..e49e7b7bdd 100755 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -933,14 +933,14 @@ int CJabberProto::SendMsg(MCONTACT hContact, int unused_unknown, const char *psz } } + CMStringA szBody; int isEncrypted, id = SerialNext(); if (!strncmp(pszSrc, PGP_PROLOG, mir_strlen(PGP_PROLOG))) { const char *szEnd = strstr(pszSrc, PGP_EPILOG); - char *tempstring = (char *)alloca(mir_strlen(pszSrc) + 2); size_t nStrippedLength = mir_strlen(pszSrc) - mir_strlen(PGP_PROLOG) - (szEnd ? mir_strlen(szEnd) : 0) + 1; - strncpy_s(tempstring, nStrippedLength, pszSrc + mir_strlen(PGP_PROLOG), _TRUNCATE); - tempstring[nStrippedLength] = 0; - pszSrc = tempstring; + szBody.Append(pszSrc + mir_strlen(PGP_PROLOG), nStrippedLength); + szBody.Replace("\r\n", ""); + pszSrc = szBody; isEncrypted = 1; } else isEncrypted = 0; @@ -966,7 +966,7 @@ int CJabberProto::SendMsg(MCONTACT hContact, int unused_unknown, const char *psz m << XCHILD("body", pszSrc); else { m << XCHILD("body", "[This message is encrypted.]"); - m << XCHILDNS("x", "jabber:x:encrypted"); + m << XCHILD("x", pszSrc) << XATTR("xmlns", "jabber:x:encrypted"); } } -- cgit v1.2.3