diff options
author | George Hazan <ghazan@miranda.im> | 2022-11-20 18:04:42 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2022-11-20 18:04:42 +0300 |
commit | 6515f53752df7b3f754879ff6c7dc1e224185587 (patch) | |
tree | 4c72854187fc095db910116a4464c93f6227207c /protocols/WhatsApp | |
parent | e11b467c11b01de711d5641b7aaa2f3bdb3fd398 (diff) |
WhatsApp: fix for hex strings encoding
Diffstat (limited to 'protocols/WhatsApp')
-rw-r--r-- | protocols/WhatsApp/src/utils.h | 7 | ||||
-rw-r--r-- | protocols/WhatsApp/src/wanode.cpp | 12 |
2 files changed, 9 insertions, 10 deletions
diff --git a/protocols/WhatsApp/src/utils.h b/protocols/WhatsApp/src/utils.h index d55e816d8c..02882f1c17 100644 --- a/protocols/WhatsApp/src/utils.h +++ b/protocols/WhatsApp/src/utils.h @@ -180,11 +180,10 @@ struct WASendTask payLoad("message"), arDest(1) { - __int64 msgId; + uint8_t msgId[8]; Utils_GetRandom(&msgId, sizeof(msgId)); - if (msgId < 0) - msgId = -msgId; - _i64toa(msgId, szMsgId, 10); + bin2hex(msgId, sizeof(msgId), szMsgId); + strupr(szMsgId); payLoad << CHAR_PARAM("id", szMsgId) << CHAR_PARAM("type", "text") << CHAR_PARAM("to", jid); } diff --git a/protocols/WhatsApp/src/wanode.cpp b/protocols/WhatsApp/src/wanode.cpp index f48ceaebd9..0c3fe15d03 100644 --- a/protocols/WhatsApp/src/wanode.cpp +++ b/protocols/WhatsApp/src/wanode.cpp @@ -518,17 +518,17 @@ static BYTE packNibble(char c) static BYTE packHex(char c) { - if (c == 0) - return 15; - if (c >= '0' && c <= '9') return c - '0'; if (c >= 'A' && c <= 'F') - return c - 'A'; + return 10 + c - 'A'; if (c >= 'a' && c <= 'f') - return c - 'a'; + return 10 + c - 'a'; + + if (c == 0) + return 15; return -1; } @@ -547,7 +547,7 @@ static bool isNibble(const CMStringA &str) static bool isHex(const CMStringA &str) { - return strspn(str, "0123456789abcdefABCDEF-.") == str.GetLength(); + return strspn(str, "0123456789abcdefABCDEF") == str.GetLength(); } void WAWriter::writePacked(const CMStringA &str, int tag) |