Skip to content

Commit

Permalink
Merge pull request #1053 from deXol/develop
Browse files Browse the repository at this point in the history
[BLE] Handle invalid character in BLE name
  • Loading branch information
limpkin authored Jun 15, 2022
2 parents 0000aca + b14984f commit 7261dc3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/MPDeviceBleImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1906,8 +1906,14 @@ void MPDeviceBleImpl::getBleName(const MessageHandlerCbData &cb)
connect(jobs, &AsyncJobs::finished, [this, cb](const QByteArray &data)
{
Q_UNUSED(data);
/* Callback */
cb(true, "", bleProt->getFullPayload(data));
QByteArray bleNameArr = bleProt->getFullPayload(data);
if (ZERO_BYTE == bleNameArr[0] || static_cast<char>(0xFF) == bleNameArr[0])
{
// Handle invalid character in BLE name (starts with 0x00 or 0xFF)
bleNameArr = DEFAULT_BLE_NAME.toUtf8();
qWarning() << "Invalid character in BLE name";
}
cb(true, "", bleNameArr);
});

mpDev->enqueueAndRunJob(jobs);
Expand Down
2 changes: 1 addition & 1 deletion src/WSServerCon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1564,7 +1564,7 @@ void WSServerCon::processMessageBLE(QJsonObject root, const MPDeviceProgressCb &
}
else if (root["msg"] == "get_ble_name")
{
bleImpl->getBleName([this, root, bleImpl](bool success, QString, QByteArray data)
bleImpl->getBleName([this, root](bool success, QString, QByteArray data)
{
if (!WSServer::Instance()->checkClientExists(this))
return;
Expand Down

0 comments on commit 7261dc3

Please sign in to comment.