mirror of
https://gitee.com/openharmony/ability_dmsfwk
synced 2024-11-23 06:20:07 +00:00
commit
218b419682
@ -471,7 +471,7 @@ int32_t DSchedContinue::PackStartCmd(std::shared_ptr<DSchedContinueStartCmd>& cm
|
||||
HILOGE("pack start cmd failed, the bundle is not installed on local device.");
|
||||
return ret;
|
||||
}
|
||||
cmd->appVersion_ = localBundleInfo.versionCode;
|
||||
cmd->appVersion_ = static_cast<int32_t>(localBundleInfo.versionCode);
|
||||
}
|
||||
cmd->wantParams_ = *wantParams;
|
||||
return ERR_OK;
|
||||
|
@ -382,7 +382,7 @@ void DSchedContinueManager::HandleDataRecv(int32_t sessionId, std::shared_ptr<DS
|
||||
|
||||
cJSON *comvalue = cJSON_GetObjectItemCaseSensitive(cmdValue, "Command");
|
||||
if (comvalue == nullptr || !cJSON_IsNumber(comvalue)) {
|
||||
cJSON_Delete(comvalue);
|
||||
cJSON_Delete(cmdValue);
|
||||
HILOGE("parse command failed");
|
||||
return;
|
||||
}
|
||||
|
@ -252,11 +252,13 @@ void DmsContinueTime::ReadDurationInfo(const char* info)
|
||||
}
|
||||
cJSON* beginTimeItem = cJSON_GetObjectItem(durationInfo, "beginTime");
|
||||
if (beginTimeItem == NULL) {
|
||||
cJSON_Delete(durationInfo);
|
||||
return;
|
||||
}
|
||||
int64_t beginTime = beginTimeItem->valueint;
|
||||
cJSON* endTimeItem = cJSON_GetObjectItem(durationInfo, "endTime");
|
||||
if (endTimeItem == NULL) {
|
||||
cJSON_Delete(durationInfo);
|
||||
return;
|
||||
}
|
||||
int64_t endTime = endTimeItem->valueint;
|
||||
@ -293,11 +295,13 @@ void DmsContinueTime::ReadDstInfo(const char* info)
|
||||
}
|
||||
cJSON* bundleNameItem = cJSON_GetObjectItem(dstInfo, "DstBundleName");
|
||||
if (bundleNameItem == NULL) {
|
||||
cJSON_Delete(dstInfo);
|
||||
return;
|
||||
}
|
||||
std::string bundleName = bundleNameItem->valuestring;
|
||||
cJSON* abilityNameItem = cJSON_GetObjectItem(dstInfo, "DstAbilityName");
|
||||
if (abilityNameItem == NULL) {
|
||||
cJSON_Delete(dstInfo);
|
||||
return;
|
||||
}
|
||||
std::string abilityName = abilityNameItem->valuestring;
|
||||
|
@ -1377,10 +1377,11 @@ bool DistributedWant::ParseContent(const std::string& content, std::string& prop
|
||||
if (dPos != std::string::npos) {
|
||||
std::string subString = content.substr(0, dPos);
|
||||
prop = Decode(subString);
|
||||
std::size_t length = content.length() - dPos - 1;
|
||||
if (length <= 0) {
|
||||
std::size_t length = content.length();
|
||||
if (length < dPos + 1) {
|
||||
return false;
|
||||
}
|
||||
length -= dPos - 1;
|
||||
subString = content.substr(dPos + 1, length);
|
||||
value = Decode(subString);
|
||||
return true;
|
||||
@ -1645,7 +1646,10 @@ bool DistributedWant::ReadFromJson(nlohmann::json& wantJson)
|
||||
|
||||
std::string action = wantJson.at("action").get<std::string>();
|
||||
SetAction(action);
|
||||
|
||||
|
||||
if (!wantJson.at("parameters").is_string()) {
|
||||
return false;
|
||||
}
|
||||
std::string parametersString = wantJson.at("parameters").get<std::string>();
|
||||
DistributedWantParams parameters = DistributedWantParamWrapper::ParseWantParams(parametersString);
|
||||
SetParams(parameters);
|
||||
|
@ -1271,7 +1271,7 @@ bool DistributedWantParams::ReadFromParcel(Parcel& parcel)
|
||||
if (!parcel.ReadInt32(size)) {
|
||||
return false;
|
||||
}
|
||||
if (size > parcel.GetDataSize()) {
|
||||
if (size > static_cast<int32_t>(parcel.GetDataSize())) {
|
||||
return false;
|
||||
}
|
||||
for (int32_t i = 0; i < size; i++) {
|
||||
|
@ -131,41 +131,43 @@ size_t DistributedWantParamWrapper::FindMatchingBrace(const std::string& str, si
|
||||
sptr<IDistributedWantParams> DistributedWantParamWrapper::Parse(const std::string& str)
|
||||
{
|
||||
DistributedWantParams wantParams;
|
||||
if (ValidateStr(str)) {
|
||||
std::string strKey = "";
|
||||
int typeId = 0;
|
||||
for (size_t strnum = 0; strnum < str.size(); strnum++) {
|
||||
if (str[strnum] == '{' && strKey != "" && typeId == DistributedWantParams::VALUE_TYPE_WANTPARAMS) {
|
||||
size_t num = FindMatchingBrace(str, strnum);
|
||||
wantParams.SetParam(strKey, DistributedWantParamWrapper::Parse(str.substr(strnum, num - strnum + 1)));
|
||||
strKey = "";
|
||||
typeId = 0;
|
||||
strnum = num + 1;
|
||||
} else if (str[strnum] == '"') {
|
||||
if (strKey == "") {
|
||||
strnum++;
|
||||
size_t pos = str.find('"', strnum);
|
||||
if (pos != std::string::npos) {
|
||||
strKey = str.substr(strnum, pos - strnum);
|
||||
}
|
||||
strnum = pos;
|
||||
} else if (typeId == 0) {
|
||||
strnum++;
|
||||
typeId = atoi(str.substr(strnum, str.find('"', strnum) - strnum).c_str());
|
||||
if (errno == ERANGE) {
|
||||
return nullptr;
|
||||
}
|
||||
strnum = str.find('"', strnum);
|
||||
} else {
|
||||
strnum++;
|
||||
wantParams.SetParam(strKey,
|
||||
DistributedWantParams::GetInterfaceByType(typeId,
|
||||
str.substr(strnum, str.find('"', strnum) - strnum)));
|
||||
strnum = str.find('"', strnum);
|
||||
typeId = 0;
|
||||
strKey = "";
|
||||
}
|
||||
if (!ValidateStr(str)) {
|
||||
return nullptr;
|
||||
}
|
||||
std::string strKey = "";
|
||||
int typeId = 0;
|
||||
for (size_t strnum = 0; strnum < str.size(); strnum++) {
|
||||
if (str[strnum] == '{' && strKey != "" && typeId == DistributedWantParams::VALUE_TYPE_WANTPARAMS) {
|
||||
size_t num = FindMatchingBrace(str, strnum);
|
||||
wantParams.SetParam(strKey, DistributedWantParamWrapper::Parse(str.substr(strnum, num - strnum + 1)));
|
||||
strKey = "";
|
||||
typeId = 0;
|
||||
strnum = num + 1;
|
||||
} else if (str[strnum] != '"') {
|
||||
continue;
|
||||
}
|
||||
if (strKey == "") {
|
||||
strnum++;
|
||||
size_t pos = str.find('"', strnum);
|
||||
if (pos != std::string::npos) {
|
||||
strKey = str.substr(strnum, pos - strnum);
|
||||
}
|
||||
strnum = pos;
|
||||
} else if (typeId == 0) {
|
||||
strnum++;
|
||||
typeId = GerTypedId(str, strnum);
|
||||
if (errno == ERANGE) {
|
||||
return nullptr;
|
||||
}
|
||||
strnum = str.find('"', strnum);
|
||||
} else {
|
||||
strnum++;
|
||||
wantParams.SetParam(strKey,
|
||||
DistributedWantParams::GetInterfaceByType(typeId,
|
||||
str.substr(strnum, str.find('"', strnum) - strnum)));
|
||||
strnum = str.find('"', strnum);
|
||||
typeId = 0;
|
||||
strKey = "";
|
||||
}
|
||||
}
|
||||
sptr<IDistributedWantParams> iwantParams = new (std::nothrow) DistributedWantParamWrapper(wantParams);
|
||||
@ -178,7 +180,11 @@ sptr<IDistributedWantParams> DistributedWantParamWrapper::Parse(const std::strin
|
||||
int DistributedWantParamWrapper::GerTypedId(const std::string& str, size_t& strnum)
|
||||
{
|
||||
int typeId = 0;
|
||||
std::string typeIdStr = str.substr(strnum, str.find('"', strnum) - strnum);
|
||||
size_t nIdx = str.find('"', strnum);
|
||||
if (nIdx < strnum) {
|
||||
return typeId;
|
||||
}
|
||||
std::string typeIdStr = str.substr(strnum, nIdx - strnum);
|
||||
if (typeIdStr.empty()) {
|
||||
return typeId;
|
||||
}
|
||||
@ -208,7 +214,11 @@ DistributedWantParams DistributedWantParamWrapper::ParseWantParams(const std::st
|
||||
}
|
||||
if (key == "") {
|
||||
strnum++;
|
||||
key = str.substr(strnum, str.find('"', strnum) - strnum);
|
||||
size_t nIdx = str.find('"', strnum);
|
||||
if (nIdx < strnum) {
|
||||
continue;
|
||||
}
|
||||
key = str.substr(strnum, nIdx - strnum);
|
||||
strnum = str.find('"', strnum);
|
||||
} else if (typeId == 0) {
|
||||
strnum++;
|
||||
|
@ -36,6 +36,7 @@ DSchedSoftbusSession::DSchedSoftbusSession()
|
||||
isServer_ = false;
|
||||
maxSendBytesSize_ = 0;
|
||||
maxQos_ = 0;
|
||||
ResetAssembleFrag();
|
||||
}
|
||||
|
||||
DSchedSoftbusSession::DSchedSoftbusSession(SessionInfo &info)
|
||||
|
Loading…
Reference in New Issue
Block a user