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 (!validateSessionID(this->sessionID)) { + throw std::runtime_error("Error: SessionID format is wrong."); + } + if (!validateDeviceID(this->deviceID)) { + throw std::runtime_error("Error: DeviceID format is wrong."); + } checkEmptyField("pubKey", this->pubKey); checkEmptyField("notifyToken", this->notifyToken); checkEmptyField("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 (!validateDeviceID(this->fromDeviceID)) { + throw std::runtime_error("Error: FromDeviceID format is wrong."); + } + if (!validateDeviceID(this->toDeviceID)) { + throw std::runtime_error("Error: ToDeviceID format is wrong."); + } checkEmptyField("messageID", this->messageID); checkEmptyField("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 (!validateDeviceID(this->deviceID)) { + throw std::runtime_error("Error: DeviceID format is wrong."); + } checkEmptyField("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 (!validateDeviceID(this->deviceID)) { + throw std::runtime_error("Error: DeviceID format is wrong."); + } checkEmptyField("sign", this->sign); }