提交 19f8cae0 编写于 作者: X xlei1030

FIX:处理InterfaceToken校验 和 异常分支添加va_end处理问题

Signed-off-by: Nxlei1030 <xionglei6@huawei.com>
上级 58a8bbb3
......@@ -105,6 +105,7 @@ void InitLogInit(const char *outFileName, InitLogLevel logLevel, const char *kLe
if (vsnprintf_s(tmpFmt, MAX_LOG_SIZE, MAX_LOG_SIZE - 1, fmt, vargs) == -1) {
close(g_fd);
g_fd = -1;
va_end(vargs);
return;
}
......@@ -113,6 +114,7 @@ void InitLogInit(const char *outFileName, InitLogLevel logLevel, const char *kLe
kLevel, getpid(), "INIT", LOG_LEVEL_STR[logLevel], tmpFmt) == -1) {
close(g_fd);
g_fd = -1;
va_end(vargs);
return;
}
va_end(vargs);
......
......@@ -25,6 +25,7 @@ uint32_t WatcherManagerProxy::AddWatcher(const std::string &keyPrefix, const spt
WATCHER_CHECK(remote != nullptr, return 0, "Can not get remote");
MessageParcel data;
data.WriteInterfaceToken(WatcherManagerProxy::GetDescriptor());
data.WriteString(keyPrefix);
bool ret = data.WriteRemoteObject(watcher->AsObject());
WATCHER_CHECK(ret, return 0, "Can not get remote");
......@@ -42,6 +43,7 @@ int32_t WatcherManagerProxy::DelWatcher(const std::string &keyPrefix, uint32_t w
WATCHER_CHECK(remote != nullptr, return ERR_FLATTEN_OBJECT, "Can not get remote");
MessageParcel data;
data.WriteInterfaceToken(WatcherManagerProxy::GetDescriptor());
data.WriteString(keyPrefix);
data.WriteUint32(watcherId);
MessageParcel reply;
......
......@@ -22,6 +22,10 @@ namespace OHOS {
namespace init_param {
int32_t WatcherStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
{
std::u16string myDescripter = IWatcher::GetDescriptor();
std::u16string remoteDescripter = data.ReadInterfaceToken();
WATCHER_CHECK(myDescripter == remoteDescripter, return -1, "Invalid remoteDescripter");
switch (code) {
case PARAM_CHANGE: {
std::string name = data.ReadString();
......
......@@ -21,6 +21,10 @@ namespace init_param {
int32_t WatcherManagerStub::OnRemoteRequest(uint32_t code,
MessageParcel &data, MessageParcel &reply, MessageOption &option)
{
std::u16string myDescripter = IWatcherManager::GetDescriptor();
std::u16string remoteDescripter = data.ReadInterfaceToken();
WATCHER_CHECK(myDescripter == remoteDescripter, return -1, "Invalid remoteDescripter");
switch (code) {
case ADD_WATCHER: {
std::string key = data.ReadString();
......
......@@ -32,6 +32,7 @@ void WatcherProxy::OnParamerterChange(const std::string &name, const std::string
auto remote = Remote();
WATCHER_CHECK(remote != nullptr, return, "Can not get remote");
data.WriteInterfaceToken(WatcherProxy::GetDescriptor());
data.WriteString(name);
data.WriteString(value);
int ret = remote->SendRequest(PARAM_CHANGE, data, reply, option);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册