modify fuzz

Signed-off-by: wangpeng <wangpeng477@huawei.com>
This commit is contained in:
wangpggg 2024-11-19 20:04:08 +08:00
parent a90b28fbc0
commit d4a893e49c
14 changed files with 47 additions and 319 deletions

View File

@ -228,7 +228,8 @@ bool MkdirFuzzTest(const uint8_t* data, size_t size)
for (size_t i = 0; i < info.size(); i++) {
Uri parentUri(info[i].uri);
Uri newDirUri("");
result = helper->Mkdir(parentUri, "MkdirFuzzTest", newDirUri);
std::string dirName(reinterpret_cast<const char*>(data), size);
result = helper->Mkdir(parentUri, dirName, newDirUri);
if (result != OHOS::FileAccessFwk::ERR_OK) {
HILOG_ERROR("Mkdir failed. ret : %{public}d", result);
return false;
@ -272,14 +273,18 @@ bool MoveFuzzTest(const uint8_t* data, size_t size)
Uri parentUri(info[i].uri);
Uri newDirUriTest1("");
Uri newDirUriTest2("");
int result1 = helper->Mkdir(parentUri, "test1", newDirUriTest1);
int result2 = helper->Mkdir(parentUri, "test2", newDirUriTest2);
size_t len = size >> 2;
std::string test1(reinterpret_cast<const char*>(data), len);
std::string test2(reinterpret_cast<const char*>(data + len), len);
int result1 = helper->Mkdir(parentUri, test1, newDirUriTest1);
int result2 = helper->Mkdir(parentUri, test2, newDirUriTest2);
if (result1 != OHOS::FileAccessFwk::ERR_OK || result2 != OHOS::FileAccessFwk::ERR_OK) {
HILOG_ERROR("Mkdir failed. ret : %{public}d, %{public}d", result1, result2);
return false;
}
Uri testUri("");
result = helper->CreateFile(newDirUriTest1, "test.txt", testUri);
std::string test(reinterpret_cast<const char*>(data + len + len), len);
result = helper->CreateFile(newDirUriTest1, test, testUri);
if (result != OHOS::FileAccessFwk::ERR_OK) {
HILOG_ERROR("CreateFile failed. ret : %{public}d", result);
return false;
@ -321,7 +326,8 @@ bool RenameFuzzTest(const uint8_t* data, size_t size)
return false;
}
Uri renameUri("");
result = helper->Rename(newDirUriTest, "testRename", renameUri);
std::string testRename(reinterpret_cast<const char*>(data), size);
result = helper->Rename(newDirUriTest, testRename, renameUri);
if (result != OHOS::FileAccessFwk::ERR_OK) {
HILOG_ERROR("Rename failed. ret : %{public}d", result);
return false;

View File

@ -37,13 +37,6 @@ using namespace std;
using namespace OHOS;
using namespace FileAccessFwk;
using namespace AbilityRuntime;
constexpr size_t FOO_MAX_LEN = 1024;
constexpr size_t U32_AT_SIZE = 4;
enum {
TOKEN_INDEX_ONE = 0,
};
void SetNativeToken()
{
@ -71,14 +64,14 @@ void SetNativeToken()
OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo();
}
bool ExternalFileAccessAccessFuzzTest(std::unique_ptr<char[]> data, size_t size)
bool ExternalFileAccessAccessFuzzTest(const uint8_t *data, size_t size)
{
SetNativeToken();
// CMD_ACCESS
uint32_t code = 14;
MessageParcel datas;
datas.WriteInterfaceToken(FileAccessExtStub::GetDescriptor());
datas.WriteBuffer(data.get(), size);
datas.WriteBuffer(reinterpret_cast<const char*>(data), size);
datas.RewindRead(0);
MessageParcel reply;
MessageOption option;
@ -103,22 +96,6 @@ bool ExternalFileAccessAccessFuzzTest(std::unique_ptr<char[]> data, size_t size)
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
/* Run your code on data */
if (data == nullptr) {
return 0;
}
/* Validate the length of size */
if (size < OHOS::U32_AT_SIZE || size > OHOS::FOO_MAX_LEN) {
return 0;
}
auto str = std::make_unique<char[]>(size + 1);
(void)memset_s(str.get(), size + 1, 0x00, size + 1);
if (memcpy_s(str.get(), size, data, size) != EOK) {
return 0;
}
OHOS::ExternalFileAccessAccessFuzzTest(move(str), size);
OHOS::ExternalFileAccessAccessFuzzTest(data, size);
return 0;
}

View File

@ -37,13 +37,6 @@ using namespace std;
using namespace OHOS;
using namespace FileAccessFwk;
using namespace AbilityRuntime;
constexpr size_t FOO_MAX_LEN = 1024;
constexpr size_t U32_AT_SIZE = 4;
enum {
TOKEN_INDEX_ONE = 0,
};
void SetNativeToken()
{
@ -71,14 +64,14 @@ void SetNativeToken()
OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo();
}
bool ExternalFileAccessCreateFileFuzzTest(std::unique_ptr<char[]> data, size_t size)
bool ExternalFileAccessCreateFileFuzzTest(const uint8_t *data, size_t size)
{
SetNativeToken();
// CMD_CREATEILE
uint32_t code = 2;
MessageParcel datas;
datas.WriteInterfaceToken(FileAccessExtStub::GetDescriptor());
datas.WriteBuffer(data.get(), size);
datas.WriteBuffer(reinterpret_cast<const char*>(data), size);
datas.RewindRead(0);
MessageParcel reply;
MessageOption option;
@ -103,22 +96,6 @@ bool ExternalFileAccessCreateFileFuzzTest(std::unique_ptr<char[]> data, size_t s
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
/* Run your code on data */
if (data == nullptr) {
return 0;
}
/* Validate the length of size */
if (size < OHOS::U32_AT_SIZE || size > OHOS::FOO_MAX_LEN) {
return 0;
}
auto str = std::make_unique<char[]>(size + 1);
(void)memset_s(str.get(), size + 1, 0x00, size + 1);
if (memcpy_s(str.get(), size, data, size) != EOK) {
return 0;
}
OHOS::ExternalFileAccessCreateFileFuzzTest(move(str), size);
OHOS::ExternalFileAccessCreateFileFuzzTest(data, size);
return 0;
}

View File

@ -37,13 +37,6 @@ using namespace std;
using namespace OHOS;
using namespace FileAccessFwk;
using namespace AbilityRuntime;
constexpr size_t FOO_MAX_LEN = 1024;
constexpr size_t U32_AT_SIZE = 4;
enum {
TOKEN_INDEX_ONE = 0,
};
void SetNativeToken()
{
@ -71,14 +64,14 @@ void SetNativeToken()
OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo();
}
bool ExternalFileAccessDeleteFuzzTest(std::unique_ptr<char[]> data, size_t size)
bool ExternalFileAccessDeleteFuzzTest(const uint8_t *data, size_t size)
{
SetNativeToken();
// CMD_DELETE
uint32_t code = 4;
MessageParcel datas;
datas.WriteInterfaceToken(FileAccessExtStub::GetDescriptor());
datas.WriteBuffer(data.get(), size);
datas.WriteBuffer(reinterpret_cast<const char*>(data), size);
datas.RewindRead(0);
MessageParcel reply;
MessageOption option;
@ -103,22 +96,6 @@ bool ExternalFileAccessDeleteFuzzTest(std::unique_ptr<char[]> data, size_t size)
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
/* Run your code on data */
if (data == nullptr) {
return 0;
}
/* Validate the length of size */
if (size < OHOS::U32_AT_SIZE || size > OHOS::FOO_MAX_LEN) {
return 0;
}
auto str = std::make_unique<char[]>(size + 1);
(void)memset_s(str.get(), size + 1, 0x00, size + 1);
if (memcpy_s(str.get(), size, data, size) != EOK) {
return 0;
}
OHOS::ExternalFileAccessDeleteFuzzTest(move(str), size);
OHOS::ExternalFileAccessDeleteFuzzTest(data, size);
return 0;
}

View File

@ -37,13 +37,6 @@ using namespace std;
using namespace OHOS;
using namespace FileAccessFwk;
using namespace AbilityRuntime;
constexpr size_t FOO_MAX_LEN = 1024;
constexpr size_t U32_AT_SIZE = 4;
enum {
TOKEN_INDEX_ONE = 0,
};
void SetNativeToken()
{
@ -71,14 +64,14 @@ void SetNativeToken()
OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo();
}
bool ExternalFileAccessGetFileInfoFromRelativePathFuzzTest(std::unique_ptr<char[]> data, size_t size)
bool ExternalFileAccessGetFileInfoFromRelativePathFuzzTest(const uint8_t *data, size_t size)
{
SetNativeToken();
// CMD_GET_FILEINFO_FROM_RELATIVE_PATH
uint32_t code = 17;
MessageParcel datas;
datas.WriteInterfaceToken(FileAccessExtStub::GetDescriptor());
datas.WriteBuffer(data.get(), size);
datas.WriteBuffer(reinterpret_cast<const char*>(data), size);
datas.RewindRead(0);
MessageParcel reply;
MessageOption option;
@ -103,22 +96,6 @@ bool ExternalFileAccessGetFileInfoFromRelativePathFuzzTest(std::unique_ptr<char[
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
/* Run your code on data */
if (data == nullptr) {
return 0;
}
/* Validate the length of size */
if (size < OHOS::U32_AT_SIZE || size > OHOS::FOO_MAX_LEN) {
return 0;
}
auto str = std::make_unique<char[]>(size + 1);
(void)memset_s(str.get(), size + 1, 0x00, size + 1);
if (memcpy_s(str.get(), size, data, size) != EOK) {
return 0;
}
OHOS::ExternalFileAccessGetFileInfoFromRelativePathFuzzTest(move(str), size);
OHOS::ExternalFileAccessGetFileInfoFromRelativePathFuzzTest(data, size);
return 0;
}

View File

@ -37,13 +37,6 @@ using namespace std;
using namespace OHOS;
using namespace FileAccessFwk;
using namespace AbilityRuntime;
constexpr size_t FOO_MAX_LEN = 1024;
constexpr size_t U32_AT_SIZE = 4;
enum {
TOKEN_INDEX_ONE = 0,
};
void SetNativeToken()
{
@ -71,14 +64,14 @@ void SetNativeToken()
OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo();
}
bool ExternalFileAccessGetFileInfoFromUriFuzzTest(std::unique_ptr<char[]> data, size_t size)
bool ExternalFileAccessGetFileInfoFromUriFuzzTest(const uint8_t *data, size_t size)
{
SetNativeToken();
// CMD_GET_FILEINFO_FROM_URI
uint32_t code = 16;
MessageParcel datas;
datas.WriteInterfaceToken(FileAccessExtStub::GetDescriptor());
datas.WriteBuffer(data.get(), size);
datas.WriteBuffer(reinterpret_cast<const char*>(data), size);
datas.RewindRead(0);
MessageParcel reply;
MessageOption option;
@ -103,22 +96,6 @@ bool ExternalFileAccessGetFileInfoFromUriFuzzTest(std::unique_ptr<char[]> data,
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
/* Run your code on data */
if (data == nullptr) {
return 0;
}
/* Validate the length of size */
if (size < OHOS::U32_AT_SIZE || size > OHOS::FOO_MAX_LEN) {
return 0;
}
auto str = std::make_unique<char[]>(size + 1);
(void)memset_s(str.get(), size + 1, 0x00, size + 1);
if (memcpy_s(str.get(), size, data, size) != EOK) {
return 0;
}
OHOS::ExternalFileAccessGetFileInfoFromUriFuzzTest(move(str), size);
OHOS::ExternalFileAccessGetFileInfoFromUriFuzzTest(data, size);
return 0;
}

View File

@ -37,13 +37,6 @@ using namespace std;
using namespace OHOS;
using namespace FileAccessFwk;
using namespace AbilityRuntime;
constexpr size_t FOO_MAX_LEN = 1024;
constexpr size_t U32_AT_SIZE = 4;
enum {
TOKEN_INDEX_ONE = 0,
};
void SetNativeToken()
{
@ -71,14 +64,14 @@ void SetNativeToken()
OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo();
}
bool ExternalFileAccessGetRootsFuzzTest(std::unique_ptr<char[]> data, size_t size)
bool ExternalFileAccessGetRootsFuzzTest(const uint8_t *data, size_t size)
{
SetNativeToken();
// CMD_GET_ROOTS
uint32_t code = 13;
MessageParcel datas;
datas.WriteInterfaceToken(FileAccessExtStub::GetDescriptor());
datas.WriteBuffer(data.get(), size);
datas.WriteBuffer(reinterpret_cast<const char*>(data), size);
datas.RewindRead(0);
MessageParcel reply;
MessageOption option;
@ -103,22 +96,6 @@ bool ExternalFileAccessGetRootsFuzzTest(std::unique_ptr<char[]> data, size_t siz
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
/* Run your code on data */
if (data == nullptr) {
return 0;
}
/* Validate the length of size */
if (size < OHOS::U32_AT_SIZE || size > OHOS::FOO_MAX_LEN) {
return 0;
}
auto str = std::make_unique<char[]>(size + 1);
(void)memset_s(str.get(), size + 1, 0x00, size + 1);
if (memcpy_s(str.get(), size, data, size) != EOK) {
return 0;
}
OHOS::ExternalFileAccessGetRootsFuzzTest(move(str), size);
OHOS::ExternalFileAccessGetRootsFuzzTest(data, size);
return 0;
}

View File

@ -37,13 +37,6 @@ using namespace std;
using namespace OHOS;
using namespace FileAccessFwk;
using namespace AbilityRuntime;
constexpr size_t FOO_MAX_LEN = 1024;
constexpr size_t U32_AT_SIZE = 4;
enum {
TOKEN_INDEX_ONE = 0,
};
void SetNativeToken()
{
@ -71,14 +64,14 @@ void SetNativeToken()
OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo();
}
bool ExternalFileAccessListFileFuzzTest(std::unique_ptr<char[]> data, size_t size)
bool ExternalFileAccessListFileFuzzTest(const uint8_t *data, size_t size)
{
SetNativeToken();
// CMD_LISTFILE
uint32_t code = 8;
MessageParcel datas;
datas.WriteInterfaceToken(FileAccessExtStub::GetDescriptor());
datas.WriteBuffer(data.get(), size);
datas.WriteBuffer(reinterpret_cast<const char*>(data), size);
datas.RewindRead(0);
MessageParcel reply;
MessageOption option;
@ -103,22 +96,6 @@ bool ExternalFileAccessListFileFuzzTest(std::unique_ptr<char[]> data, size_t siz
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
/* Run your code on data */
if (data == nullptr) {
return 0;
}
/* Validate the length of size */
if (size < OHOS::U32_AT_SIZE || size > OHOS::FOO_MAX_LEN) {
return 0;
}
auto str = std::make_unique<char[]>(size + 1);
(void)memset_s(str.get(), size + 1, 0x00, size + 1);
if (memcpy_s(str.get(), size, data, size) != EOK) {
return 0;
}
OHOS::ExternalFileAccessListFileFuzzTest(move(str), size);
OHOS::ExternalFileAccessListFileFuzzTest(data, size);
return 0;
}

View File

@ -37,13 +37,6 @@ using namespace std;
using namespace OHOS;
using namespace FileAccessFwk;
using namespace AbilityRuntime;
constexpr size_t FOO_MAX_LEN = 1024;
constexpr size_t U32_AT_SIZE = 4;
enum {
TOKEN_INDEX_ONE = 0,
};
void SetNativeToken()
{
@ -71,14 +64,14 @@ void SetNativeToken()
OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo();
}
bool ExternalFileAccessMkdirFuzzTest(std::unique_ptr<char[]> data, size_t size)
bool ExternalFileAccessMkdirFuzzTest(const uint8_t *data, size_t size)
{
SetNativeToken();
// CMD_MKDIR
uint32_t code = 3;
MessageParcel datas;
datas.WriteInterfaceToken(FileAccessExtStub::GetDescriptor());
datas.WriteBuffer(data.get(), size);
datas.WriteBuffer(reinterpret_cast<const char*>(data), size);
datas.RewindRead(0);
MessageParcel reply;
MessageOption option;
@ -103,22 +96,6 @@ bool ExternalFileAccessMkdirFuzzTest(std::unique_ptr<char[]> data, size_t size)
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
/* Run your code on data */
if (data == nullptr) {
return 0;
}
/* Validate the length of size */
if (size < OHOS::U32_AT_SIZE || size > OHOS::FOO_MAX_LEN) {
return 0;
}
auto str = std::make_unique<char[]>(size + 1);
(void)memset_s(str.get(), size + 1, 0x00, size + 1);
if (memcpy_s(str.get(), size, data, size) != EOK) {
return 0;
}
OHOS::ExternalFileAccessMkdirFuzzTest(move(str), size);
OHOS::ExternalFileAccessMkdirFuzzTest(data, size);
return 0;
}

View File

@ -37,13 +37,6 @@ using namespace std;
using namespace OHOS;
using namespace FileAccessFwk;
using namespace AbilityRuntime;
constexpr size_t FOO_MAX_LEN = 1024;
constexpr size_t U32_AT_SIZE = 4;
enum {
TOKEN_INDEX_ONE = 0,
};
void SetNativeToken()
{
@ -71,14 +64,14 @@ void SetNativeToken()
OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo();
}
bool ExternalFileAccessMoveFuzzTest(std::unique_ptr<char[]> data, size_t size)
bool ExternalFileAccessMoveFuzzTest(const uint8_t *data, size_t size)
{
SetNativeToken();
// CMD_MOVE
uint32_t code = 5;
MessageParcel datas;
datas.WriteInterfaceToken(FileAccessExtStub::GetDescriptor());
datas.WriteBuffer(data.get(), size);
datas.WriteBuffer(reinterpret_cast<const char*>(data), size);
datas.RewindRead(0);
MessageParcel reply;
MessageOption option;
@ -103,22 +96,6 @@ bool ExternalFileAccessMoveFuzzTest(std::unique_ptr<char[]> data, size_t size)
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
/* Run your code on data */
if (data == nullptr) {
return 0;
}
/* Validate the length of size */
if (size < OHOS::U32_AT_SIZE || size > OHOS::FOO_MAX_LEN) {
return 0;
}
auto str = std::make_unique<char[]>(size + 1);
(void)memset_s(str.get(), size + 1, 0x00, size + 1);
if (memcpy_s(str.get(), size, data, size) != EOK) {
return 0;
}
OHOS::ExternalFileAccessMoveFuzzTest(move(str), size);
OHOS::ExternalFileAccessMoveFuzzTest(data, size);
return 0;
}

View File

@ -37,13 +37,6 @@ using namespace std;
using namespace OHOS;
using namespace FileAccessFwk;
using namespace AbilityRuntime;
constexpr size_t FOO_MAX_LEN = 1024;
constexpr size_t U32_AT_SIZE = 4;
enum {
TOKEN_INDEX_ONE = 0,
};
void SetNativeToken()
{
@ -71,14 +64,14 @@ void SetNativeToken()
OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo();
}
bool ExternalFileAccessOpenFileFuzzTest(std::unique_ptr<char[]> data, size_t size)
bool ExternalFileAccessOpenFileFuzzTest(const uint8_t *data, size_t size)
{
SetNativeToken();
// CMD_OPENFILE
uint32_t code = 1;
MessageParcel datas;
datas.WriteInterfaceToken(FileAccessExtStub::GetDescriptor());
datas.WriteBuffer(data.get(), size);
datas.WriteBuffer(reinterpret_cast<const char*>(data), size);
datas.RewindRead(0);
MessageParcel reply;
MessageOption option;
@ -103,22 +96,6 @@ bool ExternalFileAccessOpenFileFuzzTest(std::unique_ptr<char[]> data, size_t siz
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
/* Run your code on data */
if (data == nullptr) {
return 0;
}
/* Validate the length of size */
if (size < OHOS::U32_AT_SIZE || size > OHOS::FOO_MAX_LEN) {
return 0;
}
auto str = std::make_unique<char[]>(size + 1);
(void)memset_s(str.get(), size + 1, 0x00, size + 1);
if (memcpy_s(str.get(), size, data, size) != EOK) {
return 0;
}
OHOS::ExternalFileAccessOpenFileFuzzTest(move(str), size);
OHOS::ExternalFileAccessOpenFileFuzzTest(data, size);
return 0;
}

View File

@ -37,13 +37,6 @@ using namespace std;
using namespace OHOS;
using namespace FileAccessFwk;
using namespace AbilityRuntime;
constexpr size_t FOO_MAX_LEN = 1024;
constexpr size_t U32_AT_SIZE = 4;
enum {
TOKEN_INDEX_ONE = 0,
};
void SetNativeToken()
{
@ -71,14 +64,14 @@ void SetNativeToken()
OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo();
}
bool ExternalFileAccessRenameFuzzTest(std::unique_ptr<char[]> data, size_t size)
bool ExternalFileAccessRenameFuzzTest(const uint8_t *data, size_t size)
{
SetNativeToken();
// CMD_RENAME
uint32_t code = 7;
MessageParcel datas;
datas.WriteInterfaceToken(FileAccessExtStub::GetDescriptor());
datas.WriteBuffer(data.get(), size);
datas.WriteBuffer(reinterpret_cast<const char*>(data), size);
datas.RewindRead(0);
MessageParcel reply;
MessageOption option;
@ -103,22 +96,6 @@ bool ExternalFileAccessRenameFuzzTest(std::unique_ptr<char[]> data, size_t size)
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
/* Run your code on data */
if (data == nullptr) {
return 0;
}
/* Validate the length of size */
if (size < OHOS::U32_AT_SIZE || size > OHOS::FOO_MAX_LEN) {
return 0;
}
auto str = std::make_unique<char[]>(size + 1);
(void)memset_s(str.get(), size + 1, 0x00, size + 1);
if (memcpy_s(str.get(), size, data, size) != EOK) {
return 0;
}
OHOS::ExternalFileAccessRenameFuzzTest(move(str), size);
OHOS::ExternalFileAccessRenameFuzzTest(data, size);
return 0;
}

View File

@ -37,13 +37,6 @@ using namespace std;
using namespace OHOS;
using namespace FileAccessFwk;
using namespace AbilityRuntime;
constexpr size_t FOO_MAX_LEN = 1024;
constexpr size_t U32_AT_SIZE = 4;
enum {
TOKEN_INDEX_ONE = 0,
};
void SetNativeToken()
{
@ -71,14 +64,14 @@ void SetNativeToken()
OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo();
}
bool ExternalFileAccessScanFileFuzzTest(std::unique_ptr<char[]> data, size_t size)
bool ExternalFileAccessScanFileFuzzTest(const uint8_t *data, size_t size)
{
SetNativeToken();
// CMD_SCANFILE
uint32_t code = 9;
MessageParcel datas;
datas.WriteInterfaceToken(FileAccessExtStub::GetDescriptor());
datas.WriteBuffer(data.get(), size);
datas.WriteBuffer(reinterpret_cast<const char*>(data), size);
datas.RewindRead(0);
MessageParcel reply;
MessageOption option;
@ -103,22 +96,6 @@ bool ExternalFileAccessScanFileFuzzTest(std::unique_ptr<char[]> data, size_t siz
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
/* Run your code on data */
if (data == nullptr) {
return 0;
}
/* Validate the length of size */
if (size < OHOS::U32_AT_SIZE || size > OHOS::FOO_MAX_LEN) {
return 0;
}
auto str = std::make_unique<char[]>(size + 1);
(void)memset_s(str.get(), size + 1, 0x00, size + 1);
if (memcpy_s(str.get(), size, data, size) != EOK) {
return 0;
}
OHOS::ExternalFileAccessScanFileFuzzTest(move(str), size);
OHOS::ExternalFileAccessScanFileFuzzTest(data, size);
return 0;
}

View File

@ -1125,8 +1125,6 @@ HWTEST_F(FileExtensionNotifyTest, external_file_access_notify_0017, testing::ext
Uri fileUri("");
result = g_fah->CreateFile(newFileDir1, "uri_file", fileUri);
EXPECT_EQ(result, OHOS::FileAccessFwk::ERR_OK);
usleep(SLEEP_TIME / 10);
EXPECT_NE(g_notifyEvent, ADD_EVENT);
usleep(SLEEP_TIME);
EXPECT_EQ(g_notifyEvent, ADD_EVENT);