From 19f8cae0f1d4f04f900bd69b5c7cfef9b727b194 Mon Sep 17 00:00:00 2001 From: xlei1030 Date: Tue, 8 Mar 2022 17:34:45 +0800 Subject: [PATCH] =?UTF-8?q?FIX:=E5=A4=84=E7=90=86InterfaceToken=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=20=E5=92=8C=20=E5=BC=82=E5=B8=B8=E5=88=86=E6=94=AF?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0va=5Fend=E5=A4=84=E7=90=86=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xlei1030 --- services/log/init_log.c | 2 ++ services/param/watcher/agent/watcher_manager_proxy.cpp | 2 ++ services/param/watcher/agent/watcher_stub.cpp | 4 ++++ services/param/watcher/proxy/watcher_manager_stub.cpp | 4 ++++ services/param/watcher/proxy/watcher_proxy.cpp | 1 + 5 files changed, 13 insertions(+) diff --git a/services/log/init_log.c b/services/log/init_log.c index 8f94bfd5..37958c57 100755 --- a/services/log/init_log.c +++ b/services/log/init_log.c @@ -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); diff --git a/services/param/watcher/agent/watcher_manager_proxy.cpp b/services/param/watcher/agent/watcher_manager_proxy.cpp index 7e46b673..701dfcbb 100755 --- a/services/param/watcher/agent/watcher_manager_proxy.cpp +++ b/services/param/watcher/agent/watcher_manager_proxy.cpp @@ -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; diff --git a/services/param/watcher/agent/watcher_stub.cpp b/services/param/watcher/agent/watcher_stub.cpp index 3bc29a02..c3cc3da2 100755 --- a/services/param/watcher/agent/watcher_stub.cpp +++ b/services/param/watcher/agent/watcher_stub.cpp @@ -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(); diff --git a/services/param/watcher/proxy/watcher_manager_stub.cpp b/services/param/watcher/proxy/watcher_manager_stub.cpp index 6c1ecfe1..daf93a69 100755 --- a/services/param/watcher/proxy/watcher_manager_stub.cpp +++ b/services/param/watcher/proxy/watcher_manager_stub.cpp @@ -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(); diff --git a/services/param/watcher/proxy/watcher_proxy.cpp b/services/param/watcher/proxy/watcher_proxy.cpp index e01d279a..ae2fe81e 100755 --- a/services/param/watcher/proxy/watcher_proxy.cpp +++ b/services/param/watcher/proxy/watcher_proxy.cpp @@ -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); -- GitLab