mirror of
https://gitee.com/openharmony/communication_dsoftbus
synced 2025-02-12 05:40:41 +00:00
add invalid check for DeviceId/IP/Mac
Signed-off-by: wuchunbo <wuchunbo1@huawei.com>
This commit is contained in:
parent
c4513ea5a6
commit
eaecec1308
@ -25,7 +25,7 @@ static constexpr int IPV6_END = 15;
|
||||
|
||||
std::string WifiDirectAnonymizeMac(const std::string &mac)
|
||||
{
|
||||
if (mac.empty()) {
|
||||
if (mac.length() < MAC_ANONYMOUS_END) {
|
||||
return "";
|
||||
}
|
||||
std::string result = mac;
|
||||
@ -63,7 +63,7 @@ std::string AnonymizeIpv4(const std::string &ip)
|
||||
|
||||
static std::string AnonymizeIpv6(const std::string &ip)
|
||||
{
|
||||
if (ip.empty()) {
|
||||
if (ip.length() < IPV6_END) {
|
||||
return "";
|
||||
}
|
||||
auto result = ip;
|
||||
@ -81,7 +81,7 @@ std::string WifiDirectAnonymizeIp(const std::string &ip)
|
||||
|
||||
std::string WifiDirectAnonymizeDeviceId(const std::string &deviceId)
|
||||
{
|
||||
if (deviceId.empty()) {
|
||||
if (deviceId.length() < DEVICE_ID_PREFIX_LEN + DEVICE_ID_SUFFIX_LEN) {
|
||||
return "";
|
||||
}
|
||||
std::string result = deviceId;
|
||||
|
Loading…
x
Reference in New Issue
Block a user