chatgui: fix corrupted channel_id from non-null-terminated binary protocol

QString::fromUtf8(ch_id) read past length-prefixed string, capturing garbage.
Use fromUtf8(ch_id, ch_id_len) — length already available from bridge but was unused.
Messages now appear on refresh and unread badge correctly matches channel.
This commit is contained in:
Evgeny committed 2026-07-24 03:33:14 +03:00
1 parent fdc30d1a4e
commit 83ca0c65a4
2 files changed
+4 -5

No files matched your search

+3 -4
View File
@@ -32,9 +32,8 @@ extern "C" {
static MainWindow* s_mainWindow = nullptr;
static void onMsgReceivedCallback(const char* ch_id, int ch_id_len, uint64_t author) {
Q_UNUSED(ch_id_len);
if (s_mainWindow)
s_mainWindow->onMessageReceived(ch_id, author);
s_mainWindow->onMessageReceived(ch_id, ch_id_len, author);
}
static void onChannelUpdatedCallback(const char* ch_id, int ch_id_len) {
@@ -334,8 +333,8 @@ void MainWindow::showSettings() {
dlg.exec();
}
void MainWindow::onMessageReceived(const char* ch_id, uint64_t author) {
QString cid = QString::fromUtf8(ch_id);
void MainWindow::onMessageReceived(const char* ch_id, int ch_id_len, uint64_t author) {
QString cid = QString::fromUtf8(ch_id, ch_id_len);
DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "MainWindow::onMessageReceived ch=%s author=%llu cur=%s",
qPrintable(cid), (unsigned long long)author, qPrintable(m_currentChannelId));
if (m_db && author != m_db->myNodeId())