Compare commits

...

5 Commits

Author SHA1 Message Date
openharmony_ci 680ec0363a !19 Add issue and PR template for release
Merge pull request !19 from OpenHarmonySCM(no_reply)/add_issus_pr_template_for_release
2021-08-09 08:19:43 +00:00
openharmony_ci 3e26410b25 !25 add uid verify for ProcPutFeature
Merge pull request !25 from zjucx/OpenHarmony_1.0.1_release
2021-07-10 03:34:56 +00:00
zjucx 6358aa926e add uid verify for ProcPutFeature 2021-07-09 20:21:39 +08:00
mamingshuai 4f293b4c0a add issue and pr template 2021-04-07 14:40:31 +08:00
openharmony_ci 45e6069251 !15 删除多余的LICENSE
Merge pull request !15 from uzawa/master
2021-03-15 20:34:06 +08:00
5 changed files with 49 additions and 1 deletions

View File

@ -0,0 +1,11 @@
### 该问题是怎么引起的?
### 重现步骤
### 报错信息

View File

@ -0,0 +1,12 @@
### 相关的Issue
### 原因(目的、解决的问题等)
### 描述(做了什么,变更了什么)
### 测试用例(新增、改动、可能影响的功能)

View File

@ -162,6 +162,29 @@ int SASTORA_FindHandleByPid(SAStore *saStore, pid_t callingPid, PidHandle *handl
return INVALID_INDEX;
}
int SASTORA_FindHandleByUidPid(SAStore *saStore, uid_t callingUid, pid_t callingPid, PidHandle *handle)
{
if (saStore == NULL || saStore->maps == NULL || handle == NULL) {
return INVALID_INDEX;
}
int16 high = saStore->mapTop - 1;
int16 low = 0;
while (low <= high) {
// binary search need div 2
int16 mid = (high + low) / 2;
if (saStore->maps[mid].pid == callingPid && saStore->maps[mid].uid == callingUid) {
*handle = saStore->maps[mid];
return mid;
}
if (saStore->maps[mid].pid < callingPid) {
low = mid + 1;
continue;
}
high = mid - 1;
}
return INVALID_INDEX;
}
PidHandle SASTORA_FindPidHandleByIpcHandle(const SAStore *saStore, uint32 handle)
{
PidHandle pidHandle = {INVALID_INDEX, INVALID_INDEX, INVALID_INDEX, INVALID_INDEX};

View File

@ -75,6 +75,7 @@ static inline void SASTORA_Init(SAStore *saStore)
int SASTORA_Save(SAStore *saStore, const char *service, const char *feature, const SvcIdentity *identity);
int SASTORA_SaveHandleByPid(SAStore *saStore, PidHandle handle);
int SASTORA_FindHandleByPid(SAStore *saStore, pid_t callingPid, PidHandle *handle);
int SASTORA_FindHandleByUidPid(SAStore *saStore, uid_t callingUid, pid_t callingPid, PidHandle *handle);
SvcIdentity SASTORA_Find(SAStore *saStore, const char *service, const char *feature);
int SASTORA_ClearByPid(SAStore *saStore, pid_t pid);
PidHandle SASTORA_FindPidHandleByIpcHandle(const SAStore *saStore, uint32 handle);

View File

@ -194,10 +194,11 @@ static int32 ProcPutFeature(SamgrServer *server, const void *origin, IpcIo *req,
return EC_INVALID;
}
pid_t pid = GetCallingPid(origin);
uid_t uid = GetCallingUid(origin);
char *feature = IpcIoPopBool(req) ? NULL : (char *)IpcIoPopString(req, &len);
MUTEX_Lock(server->mtx);
PidHandle handle;
int index = SASTORA_FindHandleByPid(&server->store, pid, &handle);
int index = SASTORA_FindHandleByUidPid(&server->store, uid, pid, &handle);
if (index == INVALID_INDEX) {
MUTEX_Unlock(server->mtx);
HILOG_ERROR(HILOG_MODULE_SAMGR, "Endpoint[%d] is not register", pid);