已开启
Skip utf8 trans format expansion in Want::Marshalling for broker process #873
Skip utf8 trans format expansion in Want::Marshalling for broker process #873
已开启
m0_65533854创建于 7 天前
1 个文件变更+5-1
@@ -20,6 +20,7 @@
20#include <cstdlib>20#include <cstdlib>
21#include <regex>21#include <regex>
22#include <securec.h>22#include <securec.h>
23+#include <unistd.h>
23 24 
24#include "nlohmann/json.hpp"25#include "nlohmann/json.hpp"
25 26 
@@ -48,6 +49,7 @@ namespace AAFwk {
48namespace {49namespace {
49const std::regex NUMBER_REGEX("^[-+]?([0-9]+)([.]([0-9]+))?$");50const std::regex NUMBER_REGEX("^[-+]?([0-9]+)([.]([0-9]+))?$");
50const int32_t MAX_ALLOWED_SIZE(512 * 1024);51const int32_t MAX_ALLOWED_SIZE(512 * 1024);
52+constexpr int32_t BROKER_UID = 5557;
51 53 
52nlohmann::json BuildWantJson(const Want &want)54nlohmann::json BuildWantJson(const Want &want)
53{55{
@@ -1719,7 +1721,9 @@ bool Want::Marshalling(Parcel &parcel) const
1719{1721{
1720 std::string ipcAction = GetAction();1722 std::string ipcAction = GetAction();
1721 parcel.SetMaxCapacity(PARAM_WANT_CAPACITY_EXPANSION);1723 parcel.SetMaxCapacity(PARAM_WANT_CAPACITY_EXPANSION);
1722- if (GetBoolParam(Want::PARAM_STRING_TRANS_FORMAT_UTF8, false)) {1724+ // broker process can not use the utf8 trans format expansion
1725+ auto selfUID = getuid();
1726+ if (GetBoolParam(Want::PARAM_STRING_TRANS_FORMAT_UTF8, false) && selfUID != BROKER_UID) {
1723 bool needExpansion = true;1727 bool needExpansion = true;
1724 ipcAction = PARAM_WANT_EXPANSION_TAG + ipcAction;1728 ipcAction = PARAM_WANT_EXPANSION_TAG + ipcAction;
1725 parameters_.SetNeedExpansion(needExpansion); // add expand capacity flag1729 parameters_.SetNeedExpansion(needExpansion); // add expand capacity flag