Skip to content

Commit 3e89a05

Browse files
author
Netanel Gonen
committed
add invalid argument incase receiving uid==0
1 parent d2eb2e4 commit 3e89a05

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

components/TARGET_PSA/services/storage/common/psa_storage_common_impl.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,9 @@ psa_status_t psa_storage_set_impl(KVStore *kvstore, int32_t pid, psa_storage_uid
191191
return PSA_ERROR_NOT_SUPPORTED;
192192
}
193193

194+
if (uid == 0) {
195+
return PSA_ERROR_INVALID_ARGUMENT;
196+
}
194197
// Generate KVStore key
195198
char kv_key[PSA_STORAGE_FILE_NAME_MAX] = {'\0'};
196199
generate_fn(kv_key, PSA_STORAGE_FILE_NAME_MAX, uid, pid);
@@ -208,6 +211,10 @@ psa_status_t psa_storage_set_impl(KVStore *kvstore, int32_t pid, psa_storage_uid
208211
psa_status_t psa_storage_get_impl(KVStore *kvstore, int32_t pid, psa_storage_uid_t uid,
209212
uint32_t data_offset, uint32_t data_length, void *p_data)
210213
{
214+
if (uid == 0) {
215+
return PSA_ERROR_INVALID_ARGUMENT;
216+
}
217+
211218
// Generate KVStore key
212219
char kv_key[PSA_STORAGE_FILE_NAME_MAX] = {'\0'};
213220
generate_fn(kv_key, PSA_STORAGE_FILE_NAME_MAX, uid, pid);
@@ -242,6 +249,11 @@ psa_status_t psa_storage_get_impl(KVStore *kvstore, int32_t pid, psa_storage_uid
242249
psa_status_t psa_storage_get_info_impl(KVStore *kvstore, int32_t pid, psa_storage_uid_t uid,
243250
struct psa_storage_info_t *p_info)
244251
{
252+
253+
if (uid == 0) {
254+
return PSA_ERROR_INVALID_ARGUMENT;
255+
}
256+
245257
// Generate KVStore key
246258
char kv_key[PSA_STORAGE_FILE_NAME_MAX] = {'\0'};
247259
generate_fn(kv_key, PSA_STORAGE_FILE_NAME_MAX, uid, pid);
@@ -262,6 +274,10 @@ psa_status_t psa_storage_get_info_impl(KVStore *kvstore, int32_t pid, psa_storag
262274

263275
psa_status_t psa_storage_remove_impl(KVStore *kvstore, int32_t pid, psa_storage_uid_t uid)
264276
{
277+
if (uid == 0) {
278+
return PSA_ERROR_INVALID_ARGUMENT;
279+
}
280+
265281
// Generate KVStore key
266282
char kv_key[PSA_STORAGE_FILE_NAME_MAX] = {'\0'};
267283
generate_fn(kv_key, PSA_STORAGE_FILE_NAME_MAX, uid, pid);

components/TARGET_PSA/services/storage/its/psa_prot_internal_storage.h

100755100644
File mode changed.

0 commit comments

Comments
 (0)