diff options
author | George Hazan <ghazan@miranda.im> | 2021-02-13 18:15:30 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2021-02-13 18:15:30 +0300 |
commit | 39a3597cf974ef228630343899f1c8aea5158cde (patch) | |
tree | 8fbc7a3b596b82c6c5f0f7b5662ef606f22551f2 /protocols/Facebook/src | |
parent | 3c8e2e2e886c774cda909dbe2d121fad7d3fc295 (diff) |
fixes #2722 (Facebook: Miranda cannot receive messages fromF B messenger mobile app for IOS)
Diffstat (limited to 'protocols/Facebook/src')
-rw-r--r-- | protocols/Facebook/src/mqtt.cpp | 14 | ||||
-rw-r--r-- | protocols/Facebook/src/server.cpp | 14 |
2 files changed, 17 insertions, 11 deletions
diff --git a/protocols/Facebook/src/mqtt.cpp b/protocols/Facebook/src/mqtt.cpp index 21e4e6001e..837bdd359d 100644 --- a/protocols/Facebook/src/mqtt.cpp +++ b/protocols/Facebook/src/mqtt.cpp @@ -49,11 +49,19 @@ uint8_t *FacebookProto::doUnzip(size_t cbData, const void *pData, size_t &cbRes) zStreamOut.next_in = (uint8_t *)pData; zStreamOut.avail_out = (unsigned)dataSize; zStreamOut.next_out = (uint8_t *)pRes; - inflate(&zStreamOut, Z_FINISH); + int rc = inflate(&zStreamOut, Z_FINISH); inflateEnd(&zStreamOut); - cbRes = dataSize - zStreamOut.avail_out; - return pRes; + switch (rc) { + case Z_OK: + case Z_STREAM_END: + cbRes = dataSize - zStreamOut.avail_out; + return pRes; + } + + mir_free(pRes); + cbRes = 0; + return nullptr; } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/protocols/Facebook/src/server.cpp b/protocols/Facebook/src/server.cpp index 8c7a8d7280..013993c741 100644 --- a/protocols/Facebook/src/server.cpp +++ b/protocols/Facebook/src/server.cpp @@ -447,14 +447,12 @@ void FacebookProto::OnPublish(const char *topic, const uint8_t *p, size_t cbLen) // that might be a zipped buffer if (cbLen >= 2) { - if ((((p[0] << 8) | p[1]) % 31) == 0 && (p[0] & 0x0F) == 8) { // zip header ok - size_t dataSize; - void *pData = doUnzip(cbLen, p, dataSize); - if (pData != nullptr) { - debugLogA("UNZIP: <%s>", CMStringA((const char *)pData, (int)dataSize).c_str()); - rdr.reset(dataSize, pData); - mir_free(pData); - } + size_t dataSize; + void *pData = doUnzip(cbLen, p, dataSize); + if (pData != nullptr) { + debugLogA("UNZIP: %d bytes unzipped ok", dataSize); + rdr.reset(dataSize, pData); + mir_free(pData); } } |