Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
fix(groups): reduce group message size limit by 50
Browse files Browse the repository at this point in the history
This commit fixes errors when sending large group messages stemming from inconsistencies in reported/true max message size in c-toxcore

Fixes #5760
  • Loading branch information
Kribylet committed Aug 2, 2019
1 parent 9099eea commit 6c77d57
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/core/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1450,7 +1450,17 @@ QStringList Core::splitMessage(const QString& message)
QStringList splittedMsgs;
QByteArray ba_message{message.toUtf8()};

const auto maxLen = tox_max_message_length();
/*
* TODO: Remove this hack; the reported max message length we receive from c-toxcore
* as of 08-02-2019 is inaccurate, causing us to generate too large messages when splitting
* them up.
*
* The inconsistency lies in c-toxcore group.c:2480 using MAX_GROUP_MESSAGE_DATA_LEN to verify
* message size is within limit, but tox_max_message_length giving a different size limit to us.
*
* (uint32_t tox_max_message_length(void); declared in tox.h, unable to see explicit definition)
*/
const auto maxLen = tox_max_message_length() - 50;

while (ba_message.size() > maxLen) {
int splitPos = ba_message.lastIndexOf('\n', maxLen - 1);
Expand Down

0 comments on commit 6c77d57

Please sign in to comment.