diff --git a/interfaces/inner_api/file_access/src/file_access_ext_proxy.cpp b/interfaces/inner_api/file_access/src/file_access_ext_proxy.cpp index 27a3d054..d6efb180 100644 --- a/interfaces/inner_api/file_access/src/file_access_ext_proxy.cpp +++ b/interfaces/inner_api/file_access/src/file_access_ext_proxy.cpp @@ -705,7 +705,7 @@ int FileAccessExtProxy::Query(const Uri &uri, std::vector &columns, HILOG_ERROR("Parameter Query fail to WriteInt64 count"); return E_IPCS; } - if (count > FILE_RESULT_TYPE.size()) { + if (static_cast(count) > FILE_RESULT_TYPE.size()) { HILOG_ERROR(" The number of query operations exceeds %{public}zu ", FILE_RESULT_TYPE.size()); return EINVAL; } diff --git a/test/fuzztest/externalfileaccess_fuzzer/external_file_access_fuzzer.cpp b/test/fuzztest/externalfileaccess_fuzzer/external_file_access_fuzzer.cpp index 46a7774f..8df82c5b 100644 --- a/test/fuzztest/externalfileaccess_fuzzer/external_file_access_fuzzer.cpp +++ b/test/fuzztest/externalfileaccess_fuzzer/external_file_access_fuzzer.cpp @@ -41,10 +41,11 @@ const int UID_DEFAULT = 0; void SetNativeToken() { uint64_t tokenId; - const char **perms = new const char *[3]; - perms[0] = "ohos.permission.FILE_ACCESS_MANAGER"; - perms[1] = "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"; - perms[2] = "ohos.permission.CONNECT_FILE_ACCESS_EXTENSION"; + const char *perms[] = { + "ohos.permission.FILE_ACCESS_MANAGER", + "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "ohos.permission.CONNECT_FILE_ACCESS_EXTENSION" + }; NativeTokenInfoParams infoInstance = { .dcapsNum = 0, .permsNum = 3, @@ -61,7 +62,6 @@ void SetNativeToken() tokenId |= systemAppMask; SetSelfTokenID(tokenId); OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo(); - delete[] perms; } shared_ptr GetFileAccessHelper() diff --git a/test/fuzztest/externalfileaccessaccess_fuzzer/externalfileaccessaccess_fuzzer.cpp b/test/fuzztest/externalfileaccessaccess_fuzzer/externalfileaccessaccess_fuzzer.cpp index 18ce5d32..401cb1f4 100644 --- a/test/fuzztest/externalfileaccessaccess_fuzzer/externalfileaccessaccess_fuzzer.cpp +++ b/test/fuzztest/externalfileaccessaccess_fuzzer/externalfileaccessaccess_fuzzer.cpp @@ -48,10 +48,11 @@ enum { void SetNativeToken() { uint64_t tokenId; - const char **perms = new const char *[3]; - perms[0] = "ohos.permission.FILE_ACCESS_MANAGER"; - perms[1] = "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"; - perms[2] = "ohos.permission.CONNECT_FILE_ACCESS_EXTENSION"; + const char *perms[] = { + "ohos.permission.FILE_ACCESS_MANAGER", + "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "ohos.permission.CONNECT_FILE_ACCESS_EXTENSION" + }; NativeTokenInfoParams infoInstance = { .dcapsNum = 0, .permsNum = 3, @@ -68,7 +69,6 @@ void SetNativeToken() tokenId |= systemAppMask; SetSelfTokenID(tokenId); OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo(); - delete[] perms; } bool ExternalFileAccessAccessFuzzTest(std::unique_ptr data, size_t size) diff --git a/test/fuzztest/externalfileaccesscreatefile_fuzzer/externalfileaccesscreatefile_fuzzer.cpp b/test/fuzztest/externalfileaccesscreatefile_fuzzer/externalfileaccesscreatefile_fuzzer.cpp index c448bbf5..52a2ccaf 100644 --- a/test/fuzztest/externalfileaccesscreatefile_fuzzer/externalfileaccesscreatefile_fuzzer.cpp +++ b/test/fuzztest/externalfileaccesscreatefile_fuzzer/externalfileaccesscreatefile_fuzzer.cpp @@ -48,10 +48,11 @@ enum { void SetNativeToken() { uint64_t tokenId; - const char **perms = new const char *[3]; - perms[0] = "ohos.permission.FILE_ACCESS_MANAGER"; - perms[1] = "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"; - perms[2] = "ohos.permission.CONNECT_FILE_ACCESS_EXTENSION"; + const char *perms[] = { + "ohos.permission.FILE_ACCESS_MANAGER", + "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "ohos.permission.CONNECT_FILE_ACCESS_EXTENSION" + }; NativeTokenInfoParams infoInstance = { .dcapsNum = 0, .permsNum = 3, @@ -68,7 +69,6 @@ void SetNativeToken() tokenId |= systemAppMask; SetSelfTokenID(tokenId); OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo(); - delete[] perms; } bool ExternalFileAccessCreateFileFuzzTest(std::unique_ptr data, size_t size) diff --git a/test/fuzztest/externalfileaccessdelete_fuzzer/externalfileaccessdelete_fuzzer.cpp b/test/fuzztest/externalfileaccessdelete_fuzzer/externalfileaccessdelete_fuzzer.cpp index cbcdfa46..845ed29a 100644 --- a/test/fuzztest/externalfileaccessdelete_fuzzer/externalfileaccessdelete_fuzzer.cpp +++ b/test/fuzztest/externalfileaccessdelete_fuzzer/externalfileaccessdelete_fuzzer.cpp @@ -48,10 +48,11 @@ enum { void SetNativeToken() { uint64_t tokenId; - const char **perms = new const char *[3]; - perms[0] = "ohos.permission.FILE_ACCESS_MANAGER"; - perms[1] = "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"; - perms[2] = "ohos.permission.CONNECT_FILE_ACCESS_EXTENSION"; + const char *perms[] = { + "ohos.permission.FILE_ACCESS_MANAGER", + "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "ohos.permission.CONNECT_FILE_ACCESS_EXTENSION" + }; NativeTokenInfoParams infoInstance = { .dcapsNum = 0, .permsNum = 3, @@ -68,7 +69,6 @@ void SetNativeToken() tokenId |= systemAppMask; SetSelfTokenID(tokenId); OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo(); - delete[] perms; } bool ExternalFileAccessDeleteFuzzTest(std::unique_ptr data, size_t size) diff --git a/test/fuzztest/externalfileaccessgetfileinfofromrelativepath_fuzzer/externalfileaccessgetfileinfofromrelativepath_fuzzer.cpp b/test/fuzztest/externalfileaccessgetfileinfofromrelativepath_fuzzer/externalfileaccessgetfileinfofromrelativepath_fuzzer.cpp index 9c485975..e788cc2a 100644 --- a/test/fuzztest/externalfileaccessgetfileinfofromrelativepath_fuzzer/externalfileaccessgetfileinfofromrelativepath_fuzzer.cpp +++ b/test/fuzztest/externalfileaccessgetfileinfofromrelativepath_fuzzer/externalfileaccessgetfileinfofromrelativepath_fuzzer.cpp @@ -48,10 +48,11 @@ enum { void SetNativeToken() { uint64_t tokenId; - const char **perms = new const char *[3]; - perms[0] = "ohos.permission.FILE_ACCESS_MANAGER"; - perms[1] = "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"; - perms[2] = "ohos.permission.CONNECT_FILE_ACCESS_EXTENSION"; + const char *perms[] = { + "ohos.permission.FILE_ACCESS_MANAGER", + "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "ohos.permission.CONNECT_FILE_ACCESS_EXTENSION" + }; NativeTokenInfoParams infoInstance = { .dcapsNum = 0, .permsNum = 3, @@ -68,7 +69,6 @@ void SetNativeToken() tokenId |= systemAppMask; SetSelfTokenID(tokenId); OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo(); - delete[] perms; } bool ExternalFileAccessGetFileInfoFromRelativePathFuzzTest(std::unique_ptr data, size_t size) diff --git a/test/fuzztest/externalfileaccessgetfileinfofromuri_fuzzer/externalfileaccessgetfileinfofromuri_fuzzer.cpp b/test/fuzztest/externalfileaccessgetfileinfofromuri_fuzzer/externalfileaccessgetfileinfofromuri_fuzzer.cpp index 3ac2b456..b7182894 100644 --- a/test/fuzztest/externalfileaccessgetfileinfofromuri_fuzzer/externalfileaccessgetfileinfofromuri_fuzzer.cpp +++ b/test/fuzztest/externalfileaccessgetfileinfofromuri_fuzzer/externalfileaccessgetfileinfofromuri_fuzzer.cpp @@ -48,10 +48,11 @@ enum { void SetNativeToken() { uint64_t tokenId; - const char **perms = new const char *[3]; - perms[0] = "ohos.permission.FILE_ACCESS_MANAGER"; - perms[1] = "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"; - perms[2] = "ohos.permission.CONNECT_FILE_ACCESS_EXTENSION"; + const char *perms[] = { + "ohos.permission.FILE_ACCESS_MANAGER", + "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "ohos.permission.CONNECT_FILE_ACCESS_EXTENSION" + }; NativeTokenInfoParams infoInstance = { .dcapsNum = 0, .permsNum = 3, @@ -68,7 +69,6 @@ void SetNativeToken() tokenId |= systemAppMask; SetSelfTokenID(tokenId); OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo(); - delete[] perms; } bool ExternalFileAccessGetFileInfoFromUriFuzzTest(std::unique_ptr data, size_t size) diff --git a/test/fuzztest/externalfileaccessgetroots_fuzzer/externalfileaccessgetroots_fuzzer.cpp b/test/fuzztest/externalfileaccessgetroots_fuzzer/externalfileaccessgetroots_fuzzer.cpp index 8dc95df8..dd6855b8 100644 --- a/test/fuzztest/externalfileaccessgetroots_fuzzer/externalfileaccessgetroots_fuzzer.cpp +++ b/test/fuzztest/externalfileaccessgetroots_fuzzer/externalfileaccessgetroots_fuzzer.cpp @@ -48,10 +48,11 @@ enum { void SetNativeToken() { uint64_t tokenId; - const char **perms = new const char *[3]; - perms[0] = "ohos.permission.FILE_ACCESS_MANAGER"; - perms[1] = "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"; - perms[2] = "ohos.permission.CONNECT_FILE_ACCESS_EXTENSION"; + const char *perms[] = { + "ohos.permission.FILE_ACCESS_MANAGER", + "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "ohos.permission.CONNECT_FILE_ACCESS_EXTENSION" + }; NativeTokenInfoParams infoInstance = { .dcapsNum = 0, .permsNum = 3, @@ -68,7 +69,6 @@ void SetNativeToken() tokenId |= systemAppMask; SetSelfTokenID(tokenId); OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo(); - delete[] perms; } bool ExternalFileAccessGetRootsFuzzTest(std::unique_ptr data, size_t size) diff --git a/test/fuzztest/externalfileaccesslistfile_fuzzer/externalfileaccesslistfile_fuzzer.cpp b/test/fuzztest/externalfileaccesslistfile_fuzzer/externalfileaccesslistfile_fuzzer.cpp index 6ed737e0..54b82d4e 100644 --- a/test/fuzztest/externalfileaccesslistfile_fuzzer/externalfileaccesslistfile_fuzzer.cpp +++ b/test/fuzztest/externalfileaccesslistfile_fuzzer/externalfileaccesslistfile_fuzzer.cpp @@ -48,10 +48,11 @@ enum { void SetNativeToken() { uint64_t tokenId; - const char **perms = new const char *[3]; - perms[0] = "ohos.permission.FILE_ACCESS_MANAGER"; - perms[1] = "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"; - perms[2] = "ohos.permission.CONNECT_FILE_ACCESS_EXTENSION"; + const char *perms[] = { + "ohos.permission.FILE_ACCESS_MANAGER", + "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "ohos.permission.CONNECT_FILE_ACCESS_EXTENSION" + }; NativeTokenInfoParams infoInstance = { .dcapsNum = 0, .permsNum = 3, @@ -68,7 +69,6 @@ void SetNativeToken() tokenId |= systemAppMask; SetSelfTokenID(tokenId); OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo(); - delete[] perms; } bool ExternalFileAccessListFileFuzzTest(std::unique_ptr data, size_t size) diff --git a/test/fuzztest/externalfileaccessmkdir_fuzzer/externalfileaccessmkdir_fuzzer.cpp b/test/fuzztest/externalfileaccessmkdir_fuzzer/externalfileaccessmkdir_fuzzer.cpp index d3cfc9f0..a3655318 100644 --- a/test/fuzztest/externalfileaccessmkdir_fuzzer/externalfileaccessmkdir_fuzzer.cpp +++ b/test/fuzztest/externalfileaccessmkdir_fuzzer/externalfileaccessmkdir_fuzzer.cpp @@ -48,10 +48,11 @@ enum { void SetNativeToken() { uint64_t tokenId; - const char **perms = new const char *[3]; - perms[0] = "ohos.permission.FILE_ACCESS_MANAGER"; - perms[1] = "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"; - perms[2] = "ohos.permission.CONNECT_FILE_ACCESS_EXTENSION"; + const char *perms[] = { + "ohos.permission.FILE_ACCESS_MANAGER", + "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "ohos.permission.CONNECT_FILE_ACCESS_EXTENSION" + }; NativeTokenInfoParams infoInstance = { .dcapsNum = 0, .permsNum = 3, @@ -68,7 +69,6 @@ void SetNativeToken() tokenId |= systemAppMask; SetSelfTokenID(tokenId); OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo(); - delete[] perms; } bool ExternalFileAccessMkdirFuzzTest(std::unique_ptr data, size_t size) diff --git a/test/fuzztest/externalfileaccessmove_fuzzer/externalfileaccessmove_fuzzer.cpp b/test/fuzztest/externalfileaccessmove_fuzzer/externalfileaccessmove_fuzzer.cpp index 260a8f04..4803ca79 100644 --- a/test/fuzztest/externalfileaccessmove_fuzzer/externalfileaccessmove_fuzzer.cpp +++ b/test/fuzztest/externalfileaccessmove_fuzzer/externalfileaccessmove_fuzzer.cpp @@ -48,10 +48,11 @@ enum { void SetNativeToken() { uint64_t tokenId; - const char **perms = new const char *[3]; - perms[0] = "ohos.permission.FILE_ACCESS_MANAGER"; - perms[1] = "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"; - perms[2] = "ohos.permission.CONNECT_FILE_ACCESS_EXTENSION"; + const char *perms[] = { + "ohos.permission.FILE_ACCESS_MANAGER", + "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "ohos.permission.CONNECT_FILE_ACCESS_EXTENSION" + }; NativeTokenInfoParams infoInstance = { .dcapsNum = 0, .permsNum = 3, @@ -68,7 +69,6 @@ void SetNativeToken() tokenId |= systemAppMask; SetSelfTokenID(tokenId); OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo(); - delete[] perms; } bool ExternalFileAccessMoveFuzzTest(std::unique_ptr data, size_t size) diff --git a/test/fuzztest/externalfileaccessopenfile_fuzzer/externalfileaccessopenfile_fuzzer.cpp b/test/fuzztest/externalfileaccessopenfile_fuzzer/externalfileaccessopenfile_fuzzer.cpp index ccef60b2..2b0b82ad 100644 --- a/test/fuzztest/externalfileaccessopenfile_fuzzer/externalfileaccessopenfile_fuzzer.cpp +++ b/test/fuzztest/externalfileaccessopenfile_fuzzer/externalfileaccessopenfile_fuzzer.cpp @@ -48,10 +48,11 @@ enum { void SetNativeToken() { uint64_t tokenId; - const char **perms = new const char *[3]; - perms[0] = "ohos.permission.FILE_ACCESS_MANAGER"; - perms[1] = "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"; - perms[2] = "ohos.permission.CONNECT_FILE_ACCESS_EXTENSION"; + const char *perms[] = { + "ohos.permission.FILE_ACCESS_MANAGER", + "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "ohos.permission.CONNECT_FILE_ACCESS_EXTENSION" + }; NativeTokenInfoParams infoInstance = { .dcapsNum = 0, .permsNum = 3, @@ -68,7 +69,6 @@ void SetNativeToken() tokenId |= systemAppMask; SetSelfTokenID(tokenId); OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo(); - delete[] perms; } bool ExternalFileAccessOpenFileFuzzTest(std::unique_ptr data, size_t size) diff --git a/test/fuzztest/externalfileaccessrename_fuzzer/externalfileaccessrename_fuzzer.cpp b/test/fuzztest/externalfileaccessrename_fuzzer/externalfileaccessrename_fuzzer.cpp index 5c1a72d1..c72424bf 100644 --- a/test/fuzztest/externalfileaccessrename_fuzzer/externalfileaccessrename_fuzzer.cpp +++ b/test/fuzztest/externalfileaccessrename_fuzzer/externalfileaccessrename_fuzzer.cpp @@ -48,10 +48,11 @@ enum { void SetNativeToken() { uint64_t tokenId; - const char **perms = new const char *[3]; - perms[0] = "ohos.permission.FILE_ACCESS_MANAGER"; - perms[1] = "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"; - perms[2] = "ohos.permission.CONNECT_FILE_ACCESS_EXTENSION"; + const char *perms[] = { + "ohos.permission.FILE_ACCESS_MANAGER", + "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "ohos.permission.CONNECT_FILE_ACCESS_EXTENSION" + }; NativeTokenInfoParams infoInstance = { .dcapsNum = 0, .permsNum = 3, @@ -68,7 +69,6 @@ void SetNativeToken() tokenId |= systemAppMask; SetSelfTokenID(tokenId); OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo(); - delete[] perms; } bool ExternalFileAccessRenameFuzzTest(std::unique_ptr data, size_t size) diff --git a/test/fuzztest/externalfileaccessscanfile_fuzzer/externalfileaccessscanfile_fuzzer.cpp b/test/fuzztest/externalfileaccessscanfile_fuzzer/externalfileaccessscanfile_fuzzer.cpp index d85821a5..d5724785 100644 --- a/test/fuzztest/externalfileaccessscanfile_fuzzer/externalfileaccessscanfile_fuzzer.cpp +++ b/test/fuzztest/externalfileaccessscanfile_fuzzer/externalfileaccessscanfile_fuzzer.cpp @@ -48,10 +48,11 @@ enum { void SetNativeToken() { uint64_t tokenId; - const char **perms = new const char *[3]; - perms[0] = "ohos.permission.FILE_ACCESS_MANAGER"; - perms[1] = "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"; - perms[2] = "ohos.permission.CONNECT_FILE_ACCESS_EXTENSION"; + const char *perms[] = { + "ohos.permission.FILE_ACCESS_MANAGER", + "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "ohos.permission.CONNECT_FILE_ACCESS_EXTENSION" + }; NativeTokenInfoParams infoInstance = { .dcapsNum = 0, .permsNum = 3, @@ -68,7 +69,6 @@ void SetNativeToken() tokenId |= systemAppMask; SetSelfTokenID(tokenId); OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo(); - delete[] perms; } bool ExternalFileAccessScanFileFuzzTest(std::unique_ptr data, size_t size) diff --git a/test/fuzztest/medialibraryfileaccess_fuzzer/medialibrary_file_access_fuzzer.cpp b/test/fuzztest/medialibraryfileaccess_fuzzer/medialibrary_file_access_fuzzer.cpp index f8d8e635..76b3b4c6 100644 --- a/test/fuzztest/medialibraryfileaccess_fuzzer/medialibrary_file_access_fuzzer.cpp +++ b/test/fuzztest/medialibraryfileaccess_fuzzer/medialibrary_file_access_fuzzer.cpp @@ -41,10 +41,11 @@ const int UID_DEFAULT = 0; void SetNativeToken() { uint64_t tokenId; - const char **perms = new const char *[3]; - perms[0] = "ohos.permission.FILE_ACCESS_MANAGER"; - perms[1] = "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"; - perms[2] = "ohos.permission.CONNECT_FILE_ACCESS_EXTENSION"; + const char *perms[] = { + "ohos.permission.FILE_ACCESS_MANAGER", + "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "ohos.permission.CONNECT_FILE_ACCESS_EXTENSION" + }; NativeTokenInfoParams infoInstance = { .dcapsNum = 0, .permsNum = 3, @@ -61,7 +62,6 @@ void SetNativeToken() tokenId |= systemAppMask; SetSelfTokenID(tokenId); OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo(); - delete[] perms; } shared_ptr GetFileAccessHelper() diff --git a/test/unittest/abnormal_file_access_test.cpp b/test/unittest/abnormal_file_access_test.cpp index fff3fd46..c8f89596 100755 --- a/test/unittest/abnormal_file_access_test.cpp +++ b/test/unittest/abnormal_file_access_test.cpp @@ -40,10 +40,11 @@ shared_ptr g_context = nullptr; static void SetNativeToken(bool isSystemApp) { uint64_t tokenId; - const char **perms = new const char *[3]; - perms[0] = "ohos.permission.FILE_ACCESS_MANAGER"; - perms[1] = "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"; - perms[2] = "ohos.permission.CONNECT_FILE_ACCESS_EXTENSION"; + const char *perms[] = { + "ohos.permission.FILE_ACCESS_MANAGER", + "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "ohos.permission.CONNECT_FILE_ACCESS_EXTENSION" + }; NativeTokenInfoParams infoInstance = { .dcapsNum = 0, .permsNum = 3, @@ -62,7 +63,6 @@ static void SetNativeToken(bool isSystemApp) } SetSelfTokenID(tokenId); OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo(); - delete[] perms; } class AbnormalFileExtensionHelperTest : public testing::Test { diff --git a/test/unittest/external_file_access_test.cpp b/test/unittest/external_file_access_test.cpp index 64456883..62208f9e 100644 --- a/test/unittest/external_file_access_test.cpp +++ b/test/unittest/external_file_access_test.cpp @@ -36,10 +36,11 @@ static shared_ptr g_context = nullptr; void SetNativeToken() { uint64_t tokenId; - const char **perms = new const char *[3]; - perms[0] = "ohos.permission.FILE_ACCESS_MANAGER"; - perms[1] = "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"; - perms[2] = "ohos.permission.CONNECT_FILE_ACCESS_EXTENSION"; + const char *perms[] = { + "ohos.permission.FILE_ACCESS_MANAGER", + "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "ohos.permission.CONNECT_FILE_ACCESS_EXTENSION" + }; NativeTokenInfoParams infoInstance = { .dcapsNum = 0, .permsNum = 3, @@ -56,7 +57,6 @@ void SetNativeToken() tokenId |= systemAppMask; SetSelfTokenID(tokenId); OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo(); - delete[] perms; } void FileExtensionHelperTest::SetUpTestCase() diff --git a/test/unittest/external_notify_test.cpp b/test/unittest/external_notify_test.cpp index 98a66b94..bad7a6fb 100644 --- a/test/unittest/external_notify_test.cpp +++ b/test/unittest/external_notify_test.cpp @@ -56,10 +56,11 @@ shared_ptr g_context = nullptr; void SetNativeToken() { uint64_t tokenId; - const char **perms = new const char *[3]; - perms[0] = "ohos.permission.FILE_ACCESS_MANAGER"; - perms[1] = "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"; - perms[2] = "ohos.permission.CONNECT_FILE_ACCESS_EXTENSION"; + const char *perms[] = { + "ohos.permission.FILE_ACCESS_MANAGER", + "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "ohos.permission.CONNECT_FILE_ACCESS_EXTENSION" + }; NativeTokenInfoParams infoInstance = { .dcapsNum = 0, .permsNum = 3, @@ -76,7 +77,6 @@ void SetNativeToken() tokenId |= systemAppMask; SetSelfTokenID(tokenId); OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo(); - delete[] perms; } void SetNativeToken(const char* processName, const char*perms[], int32_t permsNum) diff --git a/test/unittest/medialibrary_file_access_test_basic.cpp b/test/unittest/medialibrary_file_access_test_basic.cpp index 25c82ce4..842ab2e7 100644 --- a/test/unittest/medialibrary_file_access_test_basic.cpp +++ b/test/unittest/medialibrary_file_access_test_basic.cpp @@ -43,10 +43,11 @@ const int UID_DEFAULT = 0; void SetNativeToken() { uint64_t tokenId; - const char **perms = new const char *[3]; - perms[0] = "ohos.permission.FILE_ACCESS_MANAGER"; - perms[1] = "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"; - perms[2] = "ohos.permission.CONNECT_FILE_ACCESS_EXTENSION"; + const char *perms[] = { + "ohos.permission.FILE_ACCESS_MANAGER", + "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "ohos.permission.CONNECT_FILE_ACCESS_EXTENSION" + }; NativeTokenInfoParams infoInstance = { .dcapsNum = 0, .permsNum = 3, @@ -63,7 +64,6 @@ void SetNativeToken() tokenId |= systemAppMask; SetSelfTokenID(tokenId); OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo(); - delete[] perms; } void FileAccessHelperTest::SetUpTestCase()