diff --git a/services/tunnelbroker/src/Database/DeviceSessionItem.cpp b/services/tunnelbroker/src/Database/DeviceSessionItem.cpp --- a/services/tunnelbroker/src/Database/DeviceSessionItem.cpp +++ b/services/tunnelbroker/src/Database/DeviceSessionItem.cpp @@ -41,6 +41,12 @@ } void DeviceSessionItem::validate() const { + if (!tools::validateSessionID(this->sessionID)) { + throw std::runtime_error("Error: SessionID format is wrong."); + } + if (!tools::validateDeviceID(this->deviceID)) { + throw std::runtime_error("Error: DeviceID format is wrong."); + } tools::checkIfNotEmpty("pubKey", this->pubKey); tools::checkIfNotEmpty("notifyToken", this->notifyToken); tools::checkIfNotEmpty("deviceType", this->deviceType); diff --git a/services/tunnelbroker/src/Database/MessageItem.cpp b/services/tunnelbroker/src/Database/MessageItem.cpp --- a/services/tunnelbroker/src/Database/MessageItem.cpp +++ b/services/tunnelbroker/src/Database/MessageItem.cpp @@ -36,6 +36,12 @@ } void MessageItem::validate() const { + if (!tools::validateDeviceID(this->fromDeviceID)) { + throw std::runtime_error("Error: FromDeviceID format is wrong."); + } + if (!tools::validateDeviceID(this->toDeviceID)) { + throw std::runtime_error("Error: ToDeviceID format is wrong."); + } tools::checkIfNotEmpty("messageID", this->messageID); tools::checkIfNotZero("expire", this->expire); } diff --git a/services/tunnelbroker/src/Database/PublicKeyItem.cpp b/services/tunnelbroker/src/Database/PublicKeyItem.cpp --- a/services/tunnelbroker/src/Database/PublicKeyItem.cpp +++ b/services/tunnelbroker/src/Database/PublicKeyItem.cpp @@ -21,6 +21,9 @@ } void PublicKeyItem::validate() const { + if (!tools::validateDeviceID(this->deviceID)) { + throw std::runtime_error("Error: DeviceID format is wrong."); + } tools::checkIfNotEmpty("publicKey", this->publicKey); } diff --git a/services/tunnelbroker/src/Database/SessionSignItem.cpp b/services/tunnelbroker/src/Database/SessionSignItem.cpp --- a/services/tunnelbroker/src/Database/SessionSignItem.cpp +++ b/services/tunnelbroker/src/Database/SessionSignItem.cpp @@ -23,6 +23,9 @@ } void SessionSignItem::validate() const { + if (!tools::validateDeviceID(this->deviceID)) { + throw std::runtime_error("Error: DeviceID format is wrong."); + } tools::checkIfNotEmpty("sign", this->sign); }