mirror of
https://github.com/openharmony/kernel_linux_build.git
synced 2026-07-19 16:24:25 -04:00
!125 fix variables case in 3.2-Beta
Merge pull request !125 from 吴凡/OpenHarmony-3.2-Beta2
This commit is contained in:
@@ -31,7 +31,7 @@ ohos_fuzztest("AccessfTokenidGrpTestFuzzTest") {
|
||||
]
|
||||
|
||||
sources = [
|
||||
"../src/accessftokenidcommon.cpp",
|
||||
"../src/accesstokenidcommon.cpp",
|
||||
"accessftokenidgrptest_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
+4
-1
@@ -14,7 +14,10 @@
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include "accessftokenidcommon.h"
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "__config"
|
||||
#include "accesstokenidcommon.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace OHOS::Kernel::AccessToken;
|
||||
|
||||
@@ -31,7 +31,7 @@ ohos_fuzztest("AccessfTokenidGrpTestOtherFuzzTest") {
|
||||
]
|
||||
|
||||
sources = [
|
||||
"../src/accessftokenidcommon.cpp",
|
||||
"../src/accesstokenidcommon.cpp",
|
||||
"accessftokenidgrptestother_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
+4
-1
@@ -14,7 +14,10 @@
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include "accessftokenidcommon.h"
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "__config"
|
||||
#include "accesstokenidcommon.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace OHOS::Kernel::AccessToken;
|
||||
|
||||
@@ -31,7 +31,7 @@ ohos_fuzztest("AccessfTokenidThreadTestFuzzTest") {
|
||||
]
|
||||
|
||||
sources = [
|
||||
"../src/accessftokenidcommon.cpp",
|
||||
"../src/accesstokenidcommon.cpp",
|
||||
"accessftokenidthreadtest_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
+4
-1
@@ -14,7 +14,10 @@
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include "accessftokenidcommon.h"
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "__config"
|
||||
#include "accesstokenidcommon.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace OHOS::Kernel::AccessToken;
|
||||
|
||||
+3
@@ -14,6 +14,9 @@
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "__config"
|
||||
#include "accesstokenidcommon.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
+3
@@ -14,6 +14,9 @@
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "__config"
|
||||
#include "accesstokenidcommon.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
+3
@@ -14,6 +14,9 @@
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "__config"
|
||||
#include "accesstokenidcommon.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -30,7 +30,7 @@ ohos_fuzztest("GetfTokenidCmdCorrectFuzzTest") {
|
||||
]
|
||||
|
||||
sources = [
|
||||
"../src/accessftokenidcommon.cpp",
|
||||
"../src/accesstokenidcommon.cpp",
|
||||
"getftokenidcmdcorrect_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
+5
-8
@@ -14,20 +14,17 @@
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include "accessftokenidcommon.h"
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "__config"
|
||||
#include "accesstokenidcommon.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace OHOS::Kernel::AccessToken;
|
||||
namespace OHOS {
|
||||
bool GetfTokenidCmdCorrectFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
bool ret = false;
|
||||
if ((data == nullptr) || (size < sizeof(unsigned long long))) {
|
||||
return ret;
|
||||
} else {
|
||||
unsigned long long tokenId = *(reinterpret_cast<const unsigned long long *>(data));
|
||||
ret = GetfTokenid(&tokenId);
|
||||
}
|
||||
bool ret = GetfTokenidCmdFuzzTest(data, size);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ ohos_fuzztest("GetfTokenidCmdErrorFuzzTest") {
|
||||
]
|
||||
|
||||
sources = [
|
||||
"../src/accessftokenidcommon.cpp",
|
||||
"../src/accesstokenidcommon.cpp",
|
||||
"getftokenidcmderror_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
+5
-8
@@ -14,21 +14,18 @@
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "__config"
|
||||
#define CMDERROR
|
||||
#include "accessftokenidcommon.h"
|
||||
#include "accesstokenidcommon.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace OHOS::Kernel::AccessToken;
|
||||
namespace OHOS {
|
||||
bool GetfTokenidCmdCorrectFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
bool ret = false;
|
||||
if ((data == nullptr) || (size < sizeof(unsigned long long))) {
|
||||
return ret;
|
||||
} else {
|
||||
unsigned long long tokenId = *(reinterpret_cast<const unsigned long long *>(data));
|
||||
ret = GetfTokenid(&tokenId);
|
||||
}
|
||||
bool ret = GetfTokenidCmdFuzzTest(data, size);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef TEST_FUZZTEST_GETFTOKENIDCMDERROR_FUZZER_H
|
||||
#define TEST_FUZZTEST_GETFTOKENIDCMDERROR_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "getftokenidcmderror_fuzzer"
|
||||
|
||||
#endif // TEST_FUZZTEST_GETFTOKENIDCMDERROR_FUZZER_H
|
||||
@@ -30,7 +30,7 @@ ohos_fuzztest("GetfTokenidNullptrFuzzTest") {
|
||||
]
|
||||
|
||||
sources = [
|
||||
"../src/accessftokenidcommon.cpp",
|
||||
"../src/accesstokenidcommon.cpp",
|
||||
"getftokenidnullptr_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -16,7 +16,10 @@
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include "accessftokenidcommon.h"
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "__config"
|
||||
#include "accesstokenidcommon.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace OHOS::Kernel::AccessToken;
|
||||
|
||||
+4
-7
@@ -16,6 +16,9 @@
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "__config"
|
||||
#include "accesstokenidcommon.h"
|
||||
|
||||
using namespace std;
|
||||
@@ -23,13 +26,7 @@ using namespace OHOS::Kernel::AccessToken;
|
||||
namespace OHOS {
|
||||
bool GetTokenidCmdCorrectFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
bool ret = false;
|
||||
if ((data == nullptr) || (size < sizeof(unsigned long long))) {
|
||||
return ret;
|
||||
} else {
|
||||
unsigned long long tokenId = *(reinterpret_cast<const unsigned long long *>(data));
|
||||
ret = GetTokenid(&tokenId);
|
||||
}
|
||||
bool ret = GetTokenidCmdFuzzTest(data, size);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef TEST_FUZZTEST_GETTOKENIDCMDCORRECT_FUZZER_H
|
||||
#define TEST_FUZZTEST_GETTOKENIDCMDCORRECT_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "gettokenidcmdcorrect_fuzzer"
|
||||
|
||||
#endif // TEST_FUZZTEST_GETTOKENIDCMDCORRECT_FUZZER_H
|
||||
@@ -14,6 +14,9 @@
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "__config"
|
||||
#define CMDERROR
|
||||
#include "accesstokenidcommon.h"
|
||||
|
||||
@@ -22,13 +25,7 @@ using namespace OHOS::Kernel::AccessToken;
|
||||
namespace OHOS {
|
||||
bool GetTokenidCmdErrorFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
bool ret = false;
|
||||
if ((data == nullptr) || (size < sizeof(unsigned long long))) {
|
||||
return ret;
|
||||
} else {
|
||||
unsigned long long tokenId = *(reinterpret_cast<const unsigned long long *>(data));
|
||||
ret = GetTokenid(&tokenId);
|
||||
}
|
||||
bool ret = GetTokenidCmdFuzzTest(data, size);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "__config"
|
||||
#include "accesstokenidcommon.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ACCESSFTOKENIDCOMMON_H
|
||||
#define ACCESSFTOKENIDCOMMON_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "accessftokenidcommon"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Kernel {
|
||||
namespace AccessToken {
|
||||
#define ACCESS_TOKEN_ID_IOCTL_BASE 'A'
|
||||
|
||||
#ifdef CMDERROR
|
||||
constexpr unsigned int GET_FTOKEN_ID = 0;
|
||||
constexpr unsigned int SET_FTOKEN_ID = 0;
|
||||
#else
|
||||
constexpr unsigned int GET_FTOKEN_ID = 3;
|
||||
constexpr unsigned int SET_FTOKEN_ID = 4;
|
||||
#endif
|
||||
|
||||
#define ACCESS_TOKENID_GET_FTOKENID \
|
||||
_IOR(ACCESS_TOKEN_ID_IOCTL_BASE, GET_FTOKEN_ID, unsigned long long)
|
||||
#define ACCESS_TOKENID_SET_FTOKENID \
|
||||
_IOW(ACCESS_TOKEN_ID_IOCTL_BASE, SET_FTOKEN_ID, unsigned long long)
|
||||
|
||||
#define LIST_NUM_1 1
|
||||
#define LIST_NUM_2 2
|
||||
#define TEST_VALUE 123
|
||||
#define CHILDREN_NUM 3
|
||||
#define WAIT_FOR_SHELL_OP_TIME 1
|
||||
#define FATHER_WAIT_TIME (WAIT_FOR_SHELL_OP_TIME * (CHILDREN_NUM + 1))
|
||||
|
||||
#define ACCESS_TOKEN_UID 3020
|
||||
#define ACCESS_TOKEN_GRPID 3020
|
||||
|
||||
#define ACCESS_TOKEN_OTHER_UID 1234
|
||||
#define ACCESS_TOKEN_OTHER_GRPID 1234
|
||||
|
||||
#define INVAL_TOKEN 0xffffffffffffffff
|
||||
|
||||
int GetfTokenid(unsigned long long *ftoken);
|
||||
int SetfTokenid(unsigned long long *ftoken);
|
||||
|
||||
void SetUidAndGrp();
|
||||
void SetUidAndGrpOther();
|
||||
void GetCurfToken(unsigned long long *ftoken);
|
||||
void SetRandfTokenAndCheck(unsigned long long *data_ftoken);
|
||||
void fTokenTest(unsigned long long *data_ftoken);
|
||||
void ThreadTest(unsigned long long *data_ftoken);
|
||||
int AccessfTokenidThreadTest(uint8_t *data_ftoken);
|
||||
int AccessfTokenidGrpTest(uint8_t *data_ftoken);
|
||||
int AccessfTokenidGrpTestOther(uint8_t *data_ftoken);
|
||||
} // namespace AccessToken
|
||||
} // namespace Kernel
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // ACCESSTOKENIDCOMMON_H
|
||||
@@ -15,6 +15,8 @@
|
||||
|
||||
#ifndef ACCESSTOKENIDCOMMON_H
|
||||
#define ACCESSTOKENIDCOMMON_H
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#define FUZZ_PROJECT_NAME "accesstokenidcommon"
|
||||
|
||||
@@ -24,17 +26,25 @@ namespace AccessToken {
|
||||
#define ACCESS_TOKEN_ID_IOCTL_BASE 'A'
|
||||
|
||||
#ifdef CMDERROR
|
||||
constexpr unsigned int GET_TOKEN_ID = 0;
|
||||
constexpr unsigned int SET_TOKEN_ID = 0;
|
||||
constexpr unsigned int get_token_id = 0;
|
||||
constexpr unsigned int set_token_id = 0;
|
||||
constexpr unsigned int get_ftoken_id = 0;
|
||||
constexpr unsigned int set_ftoken_id = 0;
|
||||
#else
|
||||
constexpr unsigned int GET_TOKEN_ID = 1;
|
||||
constexpr unsigned int SET_TOKEN_ID = 2;
|
||||
constexpr unsigned int get_token_id = 1;
|
||||
constexpr unsigned int set_token_id = 2;
|
||||
constexpr unsigned int get_ftoken_id = 3;
|
||||
constexpr unsigned int set_ftoken_id = 4;
|
||||
#endif
|
||||
|
||||
#define ACCESS_TOKENID_GET_TOKENID \
|
||||
_IOR(ACCESS_TOKEN_ID_IOCTL_BASE, GET_TOKEN_ID, unsigned long long)
|
||||
_IOR(ACCESS_TOKEN_ID_IOCTL_BASE, get_token_id, unsigned long long)
|
||||
#define ACCESS_TOKENID_SET_TOKENID \
|
||||
_IOW(ACCESS_TOKEN_ID_IOCTL_BASE, SET_TOKEN_ID, unsigned long long)
|
||||
_IOW(ACCESS_TOKEN_ID_IOCTL_BASE, set_token_id, unsigned long long)
|
||||
#define ACCESS_TOKENID_GET_FTOKENID \
|
||||
_IOR(ACCESS_TOKEN_ID_IOCTL_BASE, get_ftoken_id, unsigned long long)
|
||||
#define ACCESS_TOKENID_SET_FTOKENID \
|
||||
_IOW(ACCESS_TOKEN_ID_IOCTL_BASE, set_ftoken_id, unsigned long long)
|
||||
|
||||
#define LIST_NUM_1 1
|
||||
#define LIST_NUM_2 2
|
||||
@@ -53,6 +63,8 @@ constexpr unsigned int SET_TOKEN_ID = 2;
|
||||
|
||||
int GetTokenid(unsigned long long *token);
|
||||
int SetTokenid(unsigned long long *token);
|
||||
int GetfTokenid(unsigned long long *ftoken);
|
||||
int SetfTokenid(unsigned long long *ftoken);
|
||||
|
||||
void SetUidAndGrp();
|
||||
void SetUidAndGrpOther();
|
||||
@@ -63,6 +75,18 @@ void ThreadTest(unsigned long long *data_token);
|
||||
int AccessTokenidThreadTest(uint8_t *data_token);
|
||||
int AccessTokenidGrpTest(uint8_t *data_token);
|
||||
int AccessTokenidGrpTestOther(uint8_t *data_token);
|
||||
|
||||
void GetCurfToken(unsigned long long *ftoken);
|
||||
void SetRandfTokenAndCheck(unsigned long long *data_ftoken);
|
||||
void fTokenTest(unsigned long long *data_ftoken);
|
||||
void ThreadTest(unsigned long long *data_ftoken);
|
||||
int AccessfTokenidThreadTest(uint8_t *data_ftoken);
|
||||
int AccessfTokenidGrpTest(uint8_t *data_ftoken);
|
||||
int AccessfTokenidGrpTestOther(uint8_t *data_ftoken);
|
||||
bool SetfTokenidCmdFuzzTest(const uint8_t *data, size_t size);
|
||||
bool GetfTokenidCmdFuzzTest(const uint8_t *data, size_t size);
|
||||
bool SetTokenidCmdFuzzTest(const uint8_t *data, size_t size);
|
||||
bool GetTokenidCmdFuzzTest(const uint8_t *data, size_t size);
|
||||
} // namespace AccessToken
|
||||
} // namespace Kernel
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -30,7 +30,7 @@ ohos_fuzztest("SetfTokenidCmdCorrectFuzzTest") {
|
||||
]
|
||||
|
||||
sources = [
|
||||
"../src/accessftokenidcommon.cpp",
|
||||
"../src/accesstokenidcommon.cpp",
|
||||
"setftokenidcmdcorrect_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
+5
-8
@@ -14,20 +14,17 @@
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include "accessftokenidcommon.h"
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "__config"
|
||||
#include "accesstokenidcommon.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace OHOS::Kernel::AccessToken;
|
||||
namespace OHOS {
|
||||
bool SetfTokenidCmdCorrectFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
bool ret = false;
|
||||
if ((data == nullptr) || (size < sizeof(unsigned long long))) {
|
||||
return ret;
|
||||
} else {
|
||||
unsigned long long tokenId = *(reinterpret_cast<const unsigned long long *>(data));
|
||||
ret = SetfTokenid(&tokenId);
|
||||
}
|
||||
bool ret = SetfTokenidCmdFuzzTest(data, size);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef TEST_FUZZTEST_SETFTOKENIDCMDCORRECT_FUZZER_H
|
||||
#define TEST_FUZZTEST_SETFTOKENIDCMDCORRECT_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "setftokenidcmdcorrect_fuzzer"
|
||||
|
||||
#endif // TEST_FUZZTEST_SETFTOKENIDCMDCORRECT_FUZZER_H
|
||||
@@ -30,7 +30,7 @@ ohos_fuzztest("SetfTokenidCmdErrorFuzzTest") {
|
||||
]
|
||||
|
||||
sources = [
|
||||
"../src/accessftokenidcommon.cpp",
|
||||
"../src/accesstokenidcommon.cpp",
|
||||
"setftokenidcmderror_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
+5
-8
@@ -14,21 +14,18 @@
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "__config"
|
||||
#define CMDERROR
|
||||
#include "accessftokenidcommon.h"
|
||||
#include "accesstokenidcommon.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace OHOS::Kernel::AccessToken;
|
||||
namespace OHOS {
|
||||
bool SetfTokenidCmdErrorFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
bool ret = false;
|
||||
if ((data == nullptr) || (size < sizeof(unsigned long long))) {
|
||||
return ret;
|
||||
} else {
|
||||
unsigned long long tokenId = *(reinterpret_cast<const unsigned long long *>(data));
|
||||
ret = SetfTokenid(&tokenId);
|
||||
}
|
||||
bool ret = SetfTokenidCmdFuzzTest(data, size);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef TEST_FUZZTEST_SETFTOKENIDCMDERROR_FUZZER_H
|
||||
#define TEST_FUZZTEST_SETFTOKENIDCMDERROR_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "setftokenidcmderror_fuzzer"
|
||||
|
||||
#endif // TEST_FUZZTEST_SETFTOKENIDCMDERROR_FUZZER_H
|
||||
@@ -30,7 +30,7 @@ ohos_fuzztest("SetfTokenidNullptrFuzzTest") {
|
||||
]
|
||||
|
||||
sources = [
|
||||
"../src/accessftokenidcommon.cpp",
|
||||
"../src/accesstokenidcommon.cpp",
|
||||
"setftokenidnullptr_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -16,7 +16,10 @@
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include "accessftokenidcommon.h"
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "__config"
|
||||
#include "accesstokenidcommon.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace OHOS::Kernel::AccessToken;
|
||||
|
||||
+4
-7
@@ -16,6 +16,9 @@
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "__config"
|
||||
#include "accesstokenidcommon.h"
|
||||
|
||||
using namespace std;
|
||||
@@ -23,13 +26,7 @@ using namespace OHOS::Kernel::AccessToken;
|
||||
namespace OHOS {
|
||||
bool SetTokenidCmdCorrectFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
bool ret = false;
|
||||
if ((data == nullptr) || (size < sizeof(unsigned long long))) {
|
||||
return ret;
|
||||
} else {
|
||||
unsigned long long tokenId = *(reinterpret_cast<const unsigned long long *>(data));
|
||||
ret = SetTokenid(&tokenId);
|
||||
}
|
||||
bool ret = SetTokenidCmdFuzzTest(data, size);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef TEST_FUZZTEST_SETTOKENIDCMDCORRECT_FUZZER_H
|
||||
#define TEST_FUZZTEST_SETTOKENIDCMDCORRECT_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "settokenidcmdcorrect_fuzzer"
|
||||
|
||||
#endif // TEST_FUZZTEST_SETTOKENIDCMDCORRECT_FUZZER_H
|
||||
@@ -14,6 +14,9 @@
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "__config"
|
||||
#define CMDERROR
|
||||
#include "accesstokenidcommon.h"
|
||||
|
||||
@@ -22,13 +25,7 @@ using namespace OHOS::Kernel::AccessToken;
|
||||
namespace OHOS {
|
||||
bool SetTokenidCmdErrorFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
bool ret = false;
|
||||
if ((data == nullptr) || (size < sizeof(unsigned long long))) {
|
||||
return ret;
|
||||
} else {
|
||||
unsigned long long tokenId = *(reinterpret_cast<const unsigned long long *>(data));
|
||||
ret = SetTokenid(&tokenId);
|
||||
}
|
||||
bool ret = SetTokenidCmdFuzzTest(data, size);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "__config"
|
||||
#include "accesstokenidcommon.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -1,195 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/wait.h>
|
||||
#include <ctime>
|
||||
#include <fcntl.h>
|
||||
#include <pthread.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <vector>
|
||||
#include "accessftokenidcommon.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Kernel {
|
||||
namespace AccessToken {
|
||||
const char *DEVACCESSTOKENID = "/dev/access_token_id";
|
||||
|
||||
int GetfTokenid(unsigned long long *ftoken)
|
||||
{
|
||||
int fd = open(DEVACCESSTOKENID, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ret = ioctl(fd, ACCESS_TOKENID_GET_FTOKENID, ftoken);
|
||||
if (ret) {
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetfTokenid(unsigned long long *ftoken)
|
||||
{
|
||||
int fd = open(DEVACCESSTOKENID, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ret = ioctl(fd, ACCESS_TOKENID_SET_FTOKENID, ftoken);
|
||||
if (ret) {
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SetUidAndGrp()
|
||||
{
|
||||
int ret = 0;
|
||||
size_t groupListSize = LIST_NUM_2;
|
||||
gid_t groupList[LIST_NUM_2] = {ACCESS_TOKEN_GRPID, TEST_VALUE};
|
||||
|
||||
ret = setgroups(groupListSize, groupList);
|
||||
if (ret != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
ret = setuid(ACCESS_TOKEN_UID);
|
||||
if (ret != 0) {
|
||||
printf("SetUidAndGrp setuid error %d \n", ret);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void SetUidAndGrpOther()
|
||||
{
|
||||
int ret = 0;
|
||||
size_t groupListSize = LIST_NUM_1;
|
||||
gid_t groupList[LIST_NUM_1] = {ACCESS_TOKEN_OTHER_GRPID};
|
||||
|
||||
ret = setgroups(groupListSize, groupList);
|
||||
if (ret != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
ret = setuid(ACCESS_TOKEN_OTHER_UID);
|
||||
if (ret != 0) {
|
||||
printf("SetUidAndGrp setuid error %d \r\n", ret);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void SetRandfTokenAndCheck(unsigned long long *data_ftoken)
|
||||
{
|
||||
pid_t pid = getpid();
|
||||
pid_t tid = syscall(__NR_gettid);
|
||||
unsigned long long ftoken = INVAL_TOKEN;
|
||||
unsigned long long ftokenSet = *data_ftoken;
|
||||
|
||||
SetfTokenid(&ftokenSet);
|
||||
GetfTokenid(&ftoken);
|
||||
|
||||
if (ftoken != ftokenSet) {
|
||||
printf("pid:%d tid:%d ftoken test failed, ftoken:%llu ftokenSet:%llu\n",
|
||||
pid, tid, ftoken, ftokenSet);
|
||||
} else {
|
||||
printf("pid:%d tid:%d ftoken test succeed, ftoken:%llu ftokenSet:%llu\n",
|
||||
pid, tid, ftoken, ftokenSet);
|
||||
}
|
||||
|
||||
sleep(WAIT_FOR_SHELL_OP_TIME);
|
||||
|
||||
GetfTokenid(&ftoken);
|
||||
if (ftoken != ftokenSet) {
|
||||
printf("pid:%d tid:%d ftoken test failed, ftoken:%llu ftokenSet:%llu\n",
|
||||
pid, tid, ftoken, ftokenSet);
|
||||
} else {
|
||||
printf("pid:%d tid:%d ftoken test succeed, ftoken:%llu ftokenSet:%llu\n",
|
||||
pid, tid, ftoken, ftokenSet);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void *fTokenTest(void *data_ftoken)
|
||||
{
|
||||
SetRandfTokenAndCheck(static_cast<unsigned long long *>(data_ftoken));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ThreadTest(void *data_ftoken)
|
||||
{
|
||||
pthread_t id_1;
|
||||
pthread_t id_2;
|
||||
pthread_t id_3;
|
||||
int ret = 0;
|
||||
|
||||
ret = pthread_create(&id_1, nullptr, fTokenTest, data_ftoken);
|
||||
if (ret != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
ret = pthread_create(&id_2, nullptr, fTokenTest, data_ftoken);
|
||||
if (ret != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
ret = pthread_create(&id_3, nullptr, fTokenTest, data_ftoken);
|
||||
if (ret != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
pthread_join(id_1, nullptr);
|
||||
pthread_join(id_2, nullptr);
|
||||
pthread_join(id_3, nullptr);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int AccessfTokenidThreadTest(uint8_t *data_ftoken)
|
||||
{
|
||||
fTokenTest(static_cast<void *>(data_ftoken));
|
||||
ThreadTest(static_cast<void *>(data_ftoken));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int AccessfTokenidGrpTest(uint8_t *data_ftoken)
|
||||
{
|
||||
SetUidAndGrp();
|
||||
fTokenTest(static_cast<void *>(data_ftoken));
|
||||
ThreadTest(static_cast<void *>(data_ftoken));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int AccessfTokenidGrpTestOther(uint8_t *data_ftoken)
|
||||
{
|
||||
SetUidAndGrpOther();
|
||||
fTokenTest(static_cast<void *>(data_ftoken));
|
||||
ThreadTest(static_cast<void *>(data_ftoken));
|
||||
return 0;
|
||||
}
|
||||
} // namespace AccessToken
|
||||
} // namespace Kernel
|
||||
} // namespace OHOS
|
||||
@@ -13,16 +13,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/wait.h>
|
||||
#include <ctime>
|
||||
#include <fcntl.h>
|
||||
#include <pthread.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
#include <bits/syscall.h>
|
||||
#include <cstdio>
|
||||
#include "accesstokenidcommon.h"
|
||||
|
||||
namespace OHOS {
|
||||
@@ -187,6 +184,148 @@ int AccessTokenidGrpTestOther(uint8_t *data_token)
|
||||
ThreadTest(static_cast<void *>(data_token));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int GetfTokenid(unsigned long long *ftoken)
|
||||
{
|
||||
int fd = open(DEVACCESSTOKENID, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ret = ioctl(fd, ACCESS_TOKENID_GET_FTOKENID, ftoken);
|
||||
if (ret) {
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetfTokenid(unsigned long long *ftoken)
|
||||
{
|
||||
int fd = open(DEVACCESSTOKENID, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ret = ioctl(fd, ACCESS_TOKENID_SET_FTOKENID, ftoken);
|
||||
if (ret) {
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SetRandfTokenAndCheck(unsigned long long *data_ftoken)
|
||||
{
|
||||
pid_t pid = getpid();
|
||||
pid_t tid = syscall(__NR_gettid);
|
||||
unsigned long long ftoken = INVAL_TOKEN;
|
||||
unsigned long long ftokenSet = *data_ftoken;
|
||||
|
||||
SetfTokenid(&ftokenSet);
|
||||
GetfTokenid(&ftoken);
|
||||
|
||||
if (ftoken != ftokenSet) {
|
||||
printf("pid:%d tid:%d ftoken test failed, ftoken:%llu ftokenSet:%llu\n",
|
||||
pid, tid, ftoken, ftokenSet);
|
||||
} else {
|
||||
printf("pid:%d tid:%d ftoken test succeed, ftoken:%llu ftokenSet:%llu\n",
|
||||
pid, tid, ftoken, ftokenSet);
|
||||
}
|
||||
|
||||
sleep(WAIT_FOR_SHELL_OP_TIME);
|
||||
|
||||
GetfTokenid(&ftoken);
|
||||
if (ftoken != ftokenSet) {
|
||||
printf("pid:%d tid:%d ftoken test failed, ftoken:%llu ftokenSet:%llu\n",
|
||||
pid, tid, ftoken, ftokenSet);
|
||||
} else {
|
||||
printf("pid:%d tid:%d ftoken test succeed, ftoken:%llu ftokenSet:%llu\n",
|
||||
pid, tid, ftoken, ftokenSet);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void *fTokenTest(void *data_ftoken)
|
||||
{
|
||||
SetRandfTokenAndCheck(static_cast<unsigned long long *>(data_ftoken));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int AccessfTokenidThreadTest(uint8_t *data_ftoken)
|
||||
{
|
||||
fTokenTest(static_cast<void *>(data_ftoken));
|
||||
ThreadTest(static_cast<void *>(data_ftoken));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int AccessfTokenidGrpTest(uint8_t *data_ftoken)
|
||||
{
|
||||
SetUidAndGrp();
|
||||
fTokenTest(static_cast<void *>(data_ftoken));
|
||||
ThreadTest(static_cast<void *>(data_ftoken));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int AccessfTokenidGrpTestOther(uint8_t *data_ftoken)
|
||||
{
|
||||
SetUidAndGrpOther();
|
||||
fTokenTest(static_cast<void *>(data_ftoken));
|
||||
ThreadTest(static_cast<void *>(data_ftoken));
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool SetfTokenidCmdFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
bool ret = false;
|
||||
if ((data == nullptr) || (size < sizeof(unsigned long long))) {
|
||||
return ret;
|
||||
} else {
|
||||
unsigned long long tokenId = *(reinterpret_cast<const unsigned long long *>(data));
|
||||
ret = SetfTokenid(&tokenId);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool GetfTokenidCmdFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
bool ret = false;
|
||||
if ((data == nullptr) || (size < sizeof(unsigned long long))) {
|
||||
return ret;
|
||||
} else {
|
||||
unsigned long long tokenId = *(reinterpret_cast<const unsigned long long *>(data));
|
||||
ret = GetfTokenid(&tokenId);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool GetTokenidCmdFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
bool ret = false;
|
||||
if ((data == nullptr) || (size < sizeof(unsigned long long))) {
|
||||
return ret;
|
||||
} else {
|
||||
unsigned long long tokenId = *(reinterpret_cast<const unsigned long long *>(data));
|
||||
ret = GetTokenid(&tokenId);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool SetTokenidCmdFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
bool ret = false;
|
||||
if ((data == nullptr) || (size < sizeof(unsigned long long))) {
|
||||
return ret;
|
||||
} else {
|
||||
unsigned long long tokenId = *(reinterpret_cast<const unsigned long long *>(data));
|
||||
ret = SetTokenid(&tokenId);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
} // namespace AccessToken
|
||||
} // namespace Kernel
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -21,13 +21,18 @@ ohos_fuzztest("HcEnableFuzzTest") {
|
||||
fuzz_config_file =
|
||||
"//kernel/linux/build/test/fuzztest/hc_node/hcenable_fuzzer"
|
||||
|
||||
include_dirs = [ "../include" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
sources = [ "hcenable_fuzzer.cpp" ]
|
||||
sources = [
|
||||
"../src/hccommon.cpp",
|
||||
"hcenable_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
|
||||
@@ -15,46 +15,15 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include "hccommon.h"
|
||||
|
||||
const char *HC_ENABLE = "/sys/fs/f2fs/loop1/hc_enable";
|
||||
|
||||
namespace OHOS {
|
||||
bool HcEnableFuzzer(const uint8_t *data, size_t size)
|
||||
{
|
||||
uint32_t value = 0;
|
||||
uint32_t length = size > sizeof(uint32_t) ? sizeof(uint32_t) : size;
|
||||
int ret = access("/mnt/f2fs_mount/", F_OK);
|
||||
if (ret < 0) {
|
||||
system("mkdir -p /mnt/f2fs_mount/");
|
||||
system("mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs");
|
||||
system("losetup /dev/block/loop1 /data/image_f2fs");
|
||||
system("mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/");
|
||||
}
|
||||
|
||||
int fd = open(HC_ENABLE, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = read(fd, &value, sizeof(value));
|
||||
if (ret < 0) {
|
||||
printf("%s read fail\n", HC_ENABLE);
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = write(fd, data, length);
|
||||
if (ret < 0) {
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
close(fd);
|
||||
return true;
|
||||
bool ret = HcFuzzTest(data, HC_ENABLE, size);
|
||||
return ret;
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
||||
|
||||
@@ -21,13 +21,18 @@ ohos_fuzztest("HcHotDataLowerLimitFuzzTest") {
|
||||
fuzz_config_file =
|
||||
"//kernel/linux/build/test/fuzztest/hc_node/hchotdatalowerlimit_fuzzer"
|
||||
|
||||
include_dirs = [ "../include" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
sources = [ "hchotdatalowerlimit_fuzzer.cpp" ]
|
||||
sources = [
|
||||
"../src/hccommon.cpp",
|
||||
"hchotdatalowerlimit_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
|
||||
@@ -15,46 +15,15 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include "hccommon.h"
|
||||
|
||||
const char *HC_HOT_DATA_LOWER_LIMIT = "/sys/fs/f2fs/loop1/hc_hot_data_lower_limit";
|
||||
|
||||
namespace OHOS {
|
||||
bool HcHotDataLowerLimitFuzzer(const uint8_t *data, size_t size)
|
||||
{
|
||||
uint32_t value = 0;
|
||||
uint32_t length = size > sizeof(uint32_t) ? sizeof(uint32_t) : size;
|
||||
int ret = access("/mnt/f2fs_mount/", F_OK);
|
||||
if (ret < 0) {
|
||||
system("mkdir -p /mnt/f2fs_mount/");
|
||||
system("mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs");
|
||||
system("losetup /dev/block/loop1 /data/image_f2fs");
|
||||
system("mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/");
|
||||
}
|
||||
|
||||
int fd = open(HC_HOT_DATA_LOWER_LIMIT, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = read(fd, &value, sizeof(value));
|
||||
if (ret < 0) {
|
||||
printf("%s read fail\n", HC_HOT_DATA_LOWER_LIMIT);
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = write(fd, data, length);
|
||||
if (ret < 0) {
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
close(fd);
|
||||
return true;
|
||||
bool ret = HcFuzzTest(data, HC_HOT_DATA_LOWER_LIMIT, size);
|
||||
return ret;
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
||||
|
||||
@@ -21,13 +21,18 @@ ohos_fuzztest("HcHotDataWaterlineFuzzTest") {
|
||||
fuzz_config_file =
|
||||
"//kernel/linux/build/test/fuzztest/hc_node/hchotdatawaterline_fuzzer"
|
||||
|
||||
include_dirs = [ "../include" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
sources = [ "hchotdatawaterline_fuzzer.cpp" ]
|
||||
sources = [
|
||||
"../src/hccommon.cpp",
|
||||
"hchotdatawaterline_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
|
||||
@@ -15,46 +15,15 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include "hccommon.h"
|
||||
|
||||
const char *HC_HOT_DATA_WATERLINE = "/sys/fs/f2fs/loop1/hc_hot_data_waterline";
|
||||
|
||||
namespace OHOS {
|
||||
bool HcHotDataWaterlineFuzzer(const uint8_t *data, size_t size)
|
||||
{
|
||||
uint32_t value = 0;
|
||||
uint32_t length = size > sizeof(uint32_t) ? sizeof(uint32_t) : size;
|
||||
int ret = access("/mnt/f2fs_mount/", F_OK);
|
||||
if (ret < 0) {
|
||||
system("mkdir -p /mnt/f2fs_mount/");
|
||||
system("mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs");
|
||||
system("losetup /dev/block/loop1 /data/image_f2fs");
|
||||
system("mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/");
|
||||
}
|
||||
|
||||
int fd = open(HC_HOT_DATA_WATERLINE, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = read(fd, &value, sizeof(value));
|
||||
if (ret < 0) {
|
||||
printf("%s read fail\n", HC_HOT_DATA_WATERLINE);
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = write(fd, data, length);
|
||||
if (ret < 0) {
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
close(fd);
|
||||
return true;
|
||||
bool ret = HcFuzzTest(data, HC_HOT_DATA_WATERLINE, size);
|
||||
return ret;
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
||||
|
||||
@@ -21,13 +21,18 @@ ohos_fuzztest("HcHotNodeLowerLimitFuzzTest") {
|
||||
fuzz_config_file =
|
||||
"//kernel/linux/build/test/fuzztest/hc_node/hchotnodelowerlimit_fuzzer"
|
||||
|
||||
include_dirs = [ "../include" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
sources = [ "hchotnodelowerlimit_fuzzer.cpp" ]
|
||||
sources = [
|
||||
"../src/hccommon.cpp",
|
||||
"hchotnodelowerlimit_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
|
||||
@@ -15,46 +15,15 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include "hccommon.h"
|
||||
|
||||
const char *HC_HOT_NODE_LOWER_LIMIT = "/sys/fs/f2fs/loop1/hc_hot_node_lower_limit";
|
||||
|
||||
namespace OHOS {
|
||||
bool HcHotNodeLowerLimitFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
uint32_t value = 0;
|
||||
uint32_t length = size > sizeof(uint32_t) ? sizeof(uint32_t) : size;
|
||||
int ret = access("/mnt/f2fs_mount/", F_OK);
|
||||
if (ret < 0) {
|
||||
system("mkdir -p /mnt/f2fs_mount/");
|
||||
system("mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs");
|
||||
system("losetup /dev/block/loop1 /data/image_f2fs");
|
||||
system("mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/");
|
||||
}
|
||||
|
||||
int fd = open(HC_HOT_NODE_LOWER_LIMIT, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = read(fd, &value, sizeof(value));
|
||||
if (ret < 0) {
|
||||
printf("%s read fail\n", HC_HOT_NODE_LOWER_LIMIT);
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = write(fd, data, length);
|
||||
if (ret < 0) {
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
close(fd);
|
||||
return true;
|
||||
bool ret = HcFuzzTest(data, HC_HOT_NODE_LOWER_LIMIT, size);
|
||||
return ret;
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
||||
|
||||
@@ -21,13 +21,18 @@ ohos_fuzztest("HcHotNodeWaterLineFuzzTest") {
|
||||
fuzz_config_file =
|
||||
"//kernel/linux/build/test/fuzztest/hc_node/hchotnodewaterline_fuzzer"
|
||||
|
||||
include_dirs = [ "../include" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
sources = [ "hchotnodewaterline_fuzzer.cpp" ]
|
||||
sources = [
|
||||
"../src/hccommon.cpp",
|
||||
"hchotnodewaterline_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
|
||||
@@ -15,46 +15,15 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include "hccommon.h"
|
||||
|
||||
const char *HC_HOT_NODE_WATERLINE = "/sys/fs/f2fs/loop1/hc_hot_node_waterline";
|
||||
|
||||
namespace OHOS {
|
||||
bool HcHotNodeWaterlineFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
uint32_t value = 0;
|
||||
uint32_t length = size > sizeof(uint32_t) ? sizeof(uint32_t) : size;
|
||||
int ret = access("/mnt/f2fs_mount/", F_OK);
|
||||
if (ret < 0) {
|
||||
system("mkdir -p /mnt/f2fs_mount/");
|
||||
system("mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs");
|
||||
system("losetup /dev/block/loop1 /data/image_f2fs");
|
||||
system("mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/");
|
||||
}
|
||||
|
||||
int fd = open(HC_HOT_NODE_WATERLINE, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = read(fd, &value, sizeof(value));
|
||||
if (ret < 0) {
|
||||
printf("%s read fail\n", HC_HOT_NODE_WATERLINE);
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = write(fd, data, length);
|
||||
if (ret < 0) {
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
close(fd);
|
||||
return true;
|
||||
bool ret = HcFuzzTest(data, HC_HOT_NODE_WATERLINE, size);
|
||||
return ret;
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
||||
|
||||
@@ -20,13 +20,18 @@ ohos_fuzztest("HcWarmDataLowerLimitFuzzTest") {
|
||||
fuzz_config_file =
|
||||
"//kernel/linux/build/test/fuzztest/hc_node/hcwarmdatalowerlimit_fuzzer"
|
||||
|
||||
include_dirs = [ "../include" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
sources = [ "hcwarmdatalowerlimit_fuzzer.cpp" ]
|
||||
sources = [
|
||||
"../src/hccommon.cpp",
|
||||
"hcwarmdatalowerlimit_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
|
||||
@@ -15,46 +15,15 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include "hccommon.h"
|
||||
|
||||
const char *HC_WARM_DATA_LOWER_LIMIT = "/sys/fs/f2fs/loop1/hc_warm_data_lower_limit";
|
||||
|
||||
namespace OHOS {
|
||||
bool HcWarmDataLowerLimitFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
uint32_t value = 0;
|
||||
uint32_t length = size > sizeof(uint32_t) ? sizeof(uint32_t) : size;
|
||||
int ret = access("/mnt/f2fs_mount/", F_OK);
|
||||
if (ret < 0) {
|
||||
system("mkdir -p /mnt/f2fs_mount/");
|
||||
system("mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs");
|
||||
system("losetup /dev/block/loop1 /data/image_f2fs");
|
||||
system("mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/");
|
||||
}
|
||||
|
||||
int fd = open(HC_WARM_DATA_LOWER_LIMIT, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = read(fd, &value, sizeof(value));
|
||||
if (ret < 0) {
|
||||
printf("%s read fail\n", HC_WARM_DATA_LOWER_LIMIT);
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = write(fd, data, length);
|
||||
if (ret < 0) {
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
close(fd);
|
||||
return true;
|
||||
bool ret = HcFuzzTest(data, HC_WARM_DATA_LOWER_LIMIT, size);
|
||||
return ret;
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
||||
|
||||
@@ -20,13 +20,18 @@ ohos_fuzztest("HcWarmDataWaterLineFuzzTest") {
|
||||
fuzz_config_file =
|
||||
"//kernel/linux/build/test/fuzztest/hc_node/hcwarmdatawaterline_fuzzer"
|
||||
|
||||
include_dirs = [ "../include" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
sources = [ "hcwarmdatawaterline_fuzzer.cpp" ]
|
||||
sources = [
|
||||
"../src/hccommon.cpp",
|
||||
"hcwarmdatawaterline_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
|
||||
@@ -15,46 +15,15 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include "hccommon.h"
|
||||
|
||||
const char *HC_WARM_DATA_WATERLINE = "/sys/fs/f2fs/loop1/hc_warm_data_waterline";
|
||||
|
||||
namespace OHOS {
|
||||
bool HcWarmDataWaterLineFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
uint32_t value = 0;
|
||||
uint32_t length = size > sizeof(uint32_t) ? sizeof(uint32_t) : size;
|
||||
int ret = access("/mnt/f2fs_mount/", F_OK);
|
||||
if (ret < 0) {
|
||||
system("mkdir -p /mnt/f2fs_mount/");
|
||||
system("mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs");
|
||||
system("losetup /dev/block/loop1 /data/image_f2fs");
|
||||
system("mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/");
|
||||
}
|
||||
|
||||
int fd = open(HC_WARM_DATA_WATERLINE, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = read(fd, &value, sizeof(value));
|
||||
if (ret < 0) {
|
||||
printf("%s read fail\n", HC_WARM_DATA_WATERLINE);
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = write(fd, data, length);
|
||||
if (ret < 0) {
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
close(fd);
|
||||
return true;
|
||||
bool ret = HcFuzzTest(data, HC_WARM_DATA_WATERLINE, size);
|
||||
return ret;
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
||||
|
||||
@@ -21,13 +21,18 @@ ohos_fuzztest("HcWarmNodeLowerLimitFuzzTest") {
|
||||
fuzz_config_file =
|
||||
"//kernel/linux/build/test/fuzztest/hc_node/hcwarmnodelowerlimit_fuzzer"
|
||||
|
||||
include_dirs = [ "../include" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
sources = [ "hcwarmnodelowerlimit_fuzzer.cpp" ]
|
||||
sources = [
|
||||
"../src/hccommon.cpp",
|
||||
"hcwarmnodelowerlimit_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
|
||||
@@ -15,46 +15,15 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include "hccommon.h"
|
||||
|
||||
const char *HC_WARM_NODE_LOWER_LIMIT = "/sys/fs/f2fs/loop1/hc_warm_node_lower_limit";
|
||||
|
||||
namespace OHOS {
|
||||
bool HcWarmNodeLowerLimit(const uint8_t *data, size_t size)
|
||||
{
|
||||
uint32_t value = 0;
|
||||
uint32_t length = size > sizeof(uint32_t) ? sizeof(uint32_t) : size;
|
||||
int ret = access("/mnt/f2fs_mount/", F_OK);
|
||||
if (ret < 0) {
|
||||
system("mkdir -p /mnt/f2fs_mount/");
|
||||
system("mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs");
|
||||
system("losetup /dev/block/loop1 /data/image_f2fs");
|
||||
system("mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/");
|
||||
}
|
||||
|
||||
int fd = open(HC_WARM_NODE_LOWER_LIMIT, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = read(fd, &value, sizeof(value));
|
||||
if (ret < 0) {
|
||||
printf("%s read fail\n", HC_WARM_NODE_LOWER_LIMIT);
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = write(fd, data, length);
|
||||
if (ret < 0) {
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
close(fd);
|
||||
return true;
|
||||
bool ret = HcFuzzTest(data, HC_WARM_NODE_LOWER_LIMIT, size);
|
||||
return ret;
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
||||
|
||||
@@ -20,13 +20,18 @@ ohos_fuzztest("HcWarmNodeWaterLineFuzzTest") {
|
||||
fuzz_config_file =
|
||||
"//kernel/linux/build/test/fuzztest/hc_node/hcwarmnodewaterline_fuzzer"
|
||||
|
||||
include_dirs = [ "../include" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
sources = [ "hcwarmnodewaterline_fuzzer.cpp" ]
|
||||
sources = [
|
||||
"../src/hccommon.cpp",
|
||||
"hcwarmnodewaterline_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
|
||||
@@ -15,46 +15,15 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include "hccommon.h"
|
||||
|
||||
const char *HC_WARM_NODE_WATERLINE = "/sys/fs/f2fs/loop1/hc_warm_node_waterline";
|
||||
|
||||
namespace OHOS {
|
||||
bool HcWarmNodeLowerWaterLine(const uint8_t *data, size_t size)
|
||||
{
|
||||
uint32_t value = 0;
|
||||
uint32_t length = size > sizeof(uint32_t) ? sizeof(uint32_t) : size;
|
||||
int ret = access("/mnt/f2fs_mount/", F_OK);
|
||||
if (ret < 0) {
|
||||
system("mkdir -p /mnt/f2fs_mount/");
|
||||
system("mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs");
|
||||
system("losetup /dev/block/loop1 /data/image_f2fs");
|
||||
system("mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/");
|
||||
}
|
||||
|
||||
int fd = open(HC_WARM_NODE_WATERLINE, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = read(fd, &value, sizeof(value));
|
||||
if (ret < 0) {
|
||||
printf("%s read fail\n", HC_WARM_NODE_WATERLINE);
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = write(fd, data, length);
|
||||
if (ret < 0) {
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
close(fd);
|
||||
return true;
|
||||
bool ret = HcFuzzTest(data, HC_WARM_NODE_WATERLINE, size);
|
||||
return ret;
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
||||
|
||||
+6
-4
@@ -13,9 +13,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef TEST_FUZZTEST_SETTOKENIDCMDERROR_FUZZER_H
|
||||
#define TEST_FUZZTEST_SETTOKENIDCMDERROR_FUZZER_H
|
||||
#ifndef HCCOMMON_H
|
||||
#define HCCOMMON_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "settokenidcmderror_fuzzer"
|
||||
namespace OHOS {
|
||||
bool HcFuzzTest(const uint8_t *data, const char *pathname, size_t size);
|
||||
}
|
||||
|
||||
#endif // TEST_FUZZTEST_SETTOKENIDCMDERROR_FUZZER_H
|
||||
#endif
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <cstddef>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include "hccommon.h"
|
||||
|
||||
namespace OHOS {
|
||||
bool HcFuzzTest(const uint8_t *data, const char *pathname, size_t size)
|
||||
{
|
||||
uint32_t value = 0;
|
||||
uint32_t length = size > sizeof(uint32_t) ? sizeof(uint32_t) : size;
|
||||
int ret = access("/mnt/f2fs_mount/", F_OK);
|
||||
if (ret < 0) {
|
||||
system("mkdir -p /mnt/f2fs_mount/");
|
||||
system("mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs");
|
||||
system("losetup /dev/block/loop1 /data/image_f2fs");
|
||||
system("mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/");
|
||||
}
|
||||
|
||||
int fd = open(pathname, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = read(fd, &value, sizeof(value));
|
||||
if (ret < 0) {
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = write(fd, data, length);
|
||||
if (ret < 0) {
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
close(fd);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -20,13 +20,18 @@ ohos_fuzztest("AnonRefaultSnapshotMinIntervalFuzzTest") {
|
||||
module_out_path = module_output_path
|
||||
fuzz_config_file = "//kernel/linux/build/test/fuzztest/memory/anonrefaultsnapshotmininterval_fuzzer"
|
||||
|
||||
include_dirs = [ "../include" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
sources = [ "anonrefaultsnapshotmininterval_fuzzer.cpp" ]
|
||||
sources = [
|
||||
"../src/memorycommon.cpp",
|
||||
"anonrefaultsnapshotmininterval_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
|
||||
+4
-29
@@ -15,39 +15,14 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
const char *ANON_REFAULT_SNAPSHOT_MIN_INTERVAL = "/dev/memcg/memory.anon_refault_snapshot_min_interval";
|
||||
#include "memorycommon.h"
|
||||
|
||||
namespace OHOS {
|
||||
bool AnonRefaultSnapshotMinIntervalFuzzer(const uint8_t *data, size_t size)
|
||||
{
|
||||
uint32_t value = 0;
|
||||
|
||||
int fd = open(ANON_REFAULT_SNAPSHOT_MIN_INTERVAL, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int ret = read(fd, &value, sizeof(value));
|
||||
if (ret < 0) {
|
||||
printf("%s read fail\n", ANON_REFAULT_SNAPSHOT_MIN_INTERVAL);
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = write(fd, data, size);
|
||||
if (ret < 0) {
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return true;
|
||||
const char *anon_refault_snapshot_min_interval = "/dev/memcg/memory.anon_refault_snapshot_min_interval";
|
||||
bool ret = MemoryFuzzTest(data, size, anon_refault_snapshot_min_interval);
|
||||
return ret;
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
||||
|
||||
@@ -20,13 +20,18 @@ ohos_fuzztest("AppScoreFuzzTest") {
|
||||
module_out_path = module_output_path
|
||||
fuzz_config_file = "//kernel/linux/build/test/fuzztest/memory/appscore_fuzzer"
|
||||
|
||||
include_dirs = [ "../include" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
sources = [ "appscore_fuzzer.cpp" ]
|
||||
sources = [
|
||||
"../src/memorycommon.cpp",
|
||||
"appscore_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
|
||||
@@ -15,39 +15,14 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
const char *APP_SCORE = "/dev/memcg/memory.app_score";
|
||||
#include "memorycommon.h"
|
||||
|
||||
namespace OHOS {
|
||||
bool AppScoreFuzzer(const uint8_t *data, size_t size)
|
||||
{
|
||||
uint32_t value = 0;
|
||||
|
||||
int fd = open(APP_SCORE, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int ret = read(fd, &value, sizeof(value));
|
||||
if (ret < 0) {
|
||||
printf("%s read fail\n", APP_SCORE);
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = write(fd, data, size);
|
||||
if (ret < 0) {
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return true;
|
||||
const char *app_score = "/dev/memcg/memory.app_score";
|
||||
bool ret = MemoryFuzzTest(data, size, app_score);
|
||||
return ret;
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
||||
|
||||
@@ -20,13 +20,18 @@ ohos_fuzztest("AreaAnonRefaultThresholdFuzzTest") {
|
||||
module_out_path = module_output_path
|
||||
fuzz_config_file = "//kernel/linux/build/test/fuzztest/memory/areaanonrefaultthreshold_fuzzer"
|
||||
|
||||
include_dirs = [ "../include" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
sources = [ "areaanonrefaultthreshold_fuzzer.cpp" ]
|
||||
sources = [
|
||||
"../src/memorycommon.cpp",
|
||||
"areaanonrefaultthreshold_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
|
||||
+4
-29
@@ -15,39 +15,14 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
const char *AREA_ANON_REFAULT_THRESHOLD = "/dev/memcg/memory.area_anon_refault_threshold";
|
||||
#include "memorycommon.h"
|
||||
|
||||
namespace OHOS {
|
||||
bool AreaAnonRefaultThresholdFuzzer(const uint8_t *data, size_t size)
|
||||
{
|
||||
uint32_t value = 0;
|
||||
|
||||
int fd = open(AREA_ANON_REFAULT_THRESHOLD, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int ret = read(fd, &value, sizeof(value));
|
||||
if (ret < 0) {
|
||||
printf("%s read fail\n", AREA_ANON_REFAULT_THRESHOLD);
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = write(fd, data, size);
|
||||
if (ret < 0) {
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return true;
|
||||
const char *area_anon_refault_threshold = "/dev/memcg/memory.area_anon_refault_threshold";
|
||||
bool ret = MemoryFuzzTest(data, size, area_anon_refault_threshold);
|
||||
return ret;
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
||||
|
||||
@@ -21,13 +21,18 @@ ohos_fuzztest("AvailBuffersFuzzTest") {
|
||||
fuzz_config_file =
|
||||
"//kernel/linux/build/test/fuzztest/memory/availbuffers_fuzzer"
|
||||
|
||||
include_dirs = [ "../include" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
sources = [ "availbuffers_fuzzer.cpp" ]
|
||||
sources = [
|
||||
"../src/memorycommon.cpp",
|
||||
"availbuffers_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
|
||||
@@ -15,39 +15,14 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
const char *AVAIL_BUFFERS = "/dev/memcg/memory.avail_buffers";
|
||||
#include "memorycommon.h"
|
||||
|
||||
namespace OHOS {
|
||||
bool AvailBuffersFuzzer(const uint8_t *data, size_t size)
|
||||
{
|
||||
uint32_t value = 0;
|
||||
|
||||
int fd = open(AVAIL_BUFFERS, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int ret = read(fd, &value, sizeof(value));
|
||||
if (ret < 0) {
|
||||
printf("%s read fail\n", AVAIL_BUFFERS);
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = write(fd, data, size);
|
||||
if (ret < 0) {
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return true;
|
||||
const char *avail_buffers = "/dev/memcg/memory.avail_buffers";
|
||||
bool ret = MemoryFuzzTest(data, size, avail_buffers);
|
||||
return ret;
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
||||
|
||||
@@ -21,13 +21,18 @@ ohos_fuzztest("BufferRatioParamsFuzzTest") {
|
||||
fuzz_config_file =
|
||||
"//kernel/linux/build/test/fuzztest/memory/bufferratioparams_fuzzer"
|
||||
|
||||
include_dirs = [ "../include" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
sources = [ "bufferratioparams_fuzzer.cpp" ]
|
||||
sources = [
|
||||
"../src/memorycommon.cpp",
|
||||
"bufferratioparams_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
|
||||
@@ -15,39 +15,14 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
const char *BUFFER_RATIO_PARAMS = "/dev/memcg/memory.buffer_ratio_params";
|
||||
#include "memorycommon.h"
|
||||
|
||||
namespace OHOS {
|
||||
bool BufferRatioParamsFuzzer(const uint8_t *data, size_t size)
|
||||
{
|
||||
uint32_t value = 0;
|
||||
|
||||
int fd = open(BUFFER_RATIO_PARAMS, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int ret = read(fd, &value, sizeof(value));
|
||||
if (ret < 0) {
|
||||
printf("%s read fail\n", BUFFER_RATIO_PARAMS);
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = write(fd, data, sizeof(uint8_t));
|
||||
if (ret < 0) {
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return true;
|
||||
const char *buffer_ratio_params = "/dev/memcg/memory.buffer_ratio_params";
|
||||
bool ret = MemoryFuzzTest(data, size, buffer_ratio_params);
|
||||
return ret;
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
||||
|
||||
@@ -21,13 +21,18 @@ ohos_fuzztest("CompressRatioFuzzTest") {
|
||||
fuzz_config_file =
|
||||
"//kernel/linux/build/test/fuzztest/memory/compressratio_fuzzer"
|
||||
|
||||
include_dirs = [ "../include" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
sources = [ "compressratio_fuzzer.cpp" ]
|
||||
sources = [
|
||||
"../src/memorycommon.cpp",
|
||||
"compressratio_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
|
||||
@@ -15,39 +15,14 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
const char *COMPRESS_RATIO = "/dev/memcg/memory.compress_ratio";
|
||||
#include "memorycommon.h"
|
||||
|
||||
namespace OHOS {
|
||||
bool CompressRatioFuzzer(const uint8_t *data, size_t size)
|
||||
{
|
||||
uint32_t value = 0;
|
||||
|
||||
int fd = open(COMPRESS_RATIO, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int ret = read(fd, &value, sizeof(value));
|
||||
if (ret < 0) {
|
||||
printf("%s read fail\n", COMPRESS_RATIO);
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = write(fd, data, sizeof(uint8_t));
|
||||
if (ret < 0) {
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return true;
|
||||
const char *compress_ratio = "/dev/memcg/memory.compress_ratio";
|
||||
bool ret = MemoryFuzzTest(data, size, compress_ratio);
|
||||
return ret;
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
||||
|
||||
@@ -20,13 +20,18 @@ ohos_fuzztest("EmptyRoundCheckThresholdFuzzTest") {
|
||||
module_out_path = module_output_path
|
||||
fuzz_config_file = "//kernel/linux/build/test/fuzztest/memory/emptyroundcheckthreshold_fuzzer"
|
||||
|
||||
include_dirs = [ "../include" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
sources = [ "emptyroundcheckthreshold_fuzzer.cpp" ]
|
||||
sources = [
|
||||
"../src/memorycommon.cpp",
|
||||
"emptyroundcheckthreshold_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
|
||||
+4
-29
@@ -15,39 +15,14 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
const char *EMPTY_ROUND_CHECK_THRESHOLD = "/dev/memcg/memory.empty_round_check_threshold";
|
||||
#include "memorycommon.h"
|
||||
|
||||
namespace OHOS {
|
||||
bool EmptyRoundCheckThresholdFuzzer(const uint8_t *data, size_t size)
|
||||
{
|
||||
uint32_t value = 0;
|
||||
|
||||
int fd = open(EMPTY_ROUND_CHECK_THRESHOLD, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int ret = read(fd, &value, sizeof(value));
|
||||
if (ret < 0) {
|
||||
printf("%s read fail\n", EMPTY_ROUND_CHECK_THRESHOLD);
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = write(fd, data, size);
|
||||
if (ret < 0) {
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return true;
|
||||
const char *empty_round_check_threshold = "/dev/memcg/memory.empty_round_check_threshold";
|
||||
bool ret = MemoryFuzzTest(data, size, empty_round_check_threshold);
|
||||
return ret;
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
||||
|
||||
@@ -21,13 +21,18 @@ ohos_fuzztest("EmptyRoundSkipIntervalFuzzTest") {
|
||||
fuzz_config_file =
|
||||
"//kernel/linux/build/test/fuzztest/memory/emptyroundskipinterval_fuzzer"
|
||||
|
||||
include_dirs = [ "../include" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
sources = [ "emptyroundskipinterval_fuzzer.cpp" ]
|
||||
sources = [
|
||||
"../src/memorycommon.cpp",
|
||||
"emptyroundskipinterval_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
|
||||
+4
-29
@@ -15,39 +15,14 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
const char *EMPTY_ROUND_SKIP_INTERVAL = "/dev/memcg/memory.empty_round_skip_interval";
|
||||
#include "memorycommon.h"
|
||||
|
||||
namespace OHOS {
|
||||
bool EmptyRoundSkipIntervalFuzzer(const uint8_t *data, size_t size)
|
||||
{
|
||||
uint32_t value = 0;
|
||||
|
||||
int fd = open(EMPTY_ROUND_SKIP_INTERVAL, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int ret = read(fd, &value, sizeof(value));
|
||||
if (ret < 0) {
|
||||
printf("%s read fail\n", EMPTY_ROUND_SKIP_INTERVAL);
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = write(fd, data, size);
|
||||
if (ret < 0) {
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return true;
|
||||
const char *empty_round_skip_interval = "/dev/memcg/memory.empty_round_skip_interval";
|
||||
bool ret = MemoryFuzzTest(data, size, empty_round_skip_interval);
|
||||
return ret;
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
||||
|
||||
@@ -21,13 +21,18 @@ ohos_fuzztest("ForceShrinkAnonFuzzTest") {
|
||||
fuzz_config_file =
|
||||
"//kernel/linux/build/test/fuzztest/memory/forceshrinkanon_fuzzer"
|
||||
|
||||
include_dirs = [ "../include" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
sources = [ "forceshrinkanon_fuzzer.cpp" ]
|
||||
sources = [
|
||||
"../src/memorycommon.cpp",
|
||||
"forceshrinkanon_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
|
||||
@@ -13,27 +13,25 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
const char *FORCE_SHRINK_ANON = "/dev/memcg/memory.force_shrink_anon";
|
||||
#include <fcntl.h>
|
||||
#include "memorycommon.h"
|
||||
|
||||
namespace OHOS {
|
||||
bool ForceShrinkAnonFuzzer(const uint8_t *data, size_t size)
|
||||
{
|
||||
int fd = open(FORCE_SHRINK_ANON, O_RDWR);
|
||||
const char *force_shrink_anon = "/dev/memcg/memory.force_shrink_anon";
|
||||
int fd = open(force_shrink_anon, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int ret = write(fd, data, size);
|
||||
if (ret < 0) {
|
||||
printf("%s write fail\n", FORCE_SHRINK_ANON);
|
||||
printf("%s write fail\n", force_shrink_anon);
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
+6
-4
@@ -13,9 +13,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef TEST_FUZZTEST_GETTOKENIDCMDERROR_FUZZER_H
|
||||
#define TEST_FUZZTEST_GETTOKENIDCMDERROR_FUZZER_H
|
||||
#ifndef MEMORYCOMMON_H
|
||||
#define MEMORYCOMMON_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "gettokenidcmderror_fuzzer"
|
||||
namespace OHOS {
|
||||
bool MemoryFuzzTest(const uint8_t *data, size_t size, const char *pathname);
|
||||
}
|
||||
|
||||
#endif // TEST_FUZZTEST_GETTOKENIDCMDERROR_FUZZER_H
|
||||
#endif
|
||||
@@ -21,13 +21,18 @@ ohos_fuzztest("MaxSkipIntervalFuzzTest") {
|
||||
fuzz_config_file =
|
||||
"//kernel/linux/build/test/fuzztest/memory/maxskipinterval_fuzzer"
|
||||
|
||||
include_dirs = [ "../include" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
sources = [ "maxskipinterval_fuzzer.cpp" ]
|
||||
sources = [
|
||||
"../src/memorycommon.cpp",
|
||||
"maxskipinterval_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
|
||||
@@ -15,39 +15,14 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
const char *MAX_SKIP_INTERVAL = "/dev/memcg/memory.max_skip_interval";
|
||||
#include "memorycommon.h"
|
||||
|
||||
namespace OHOS {
|
||||
bool MaxSkipIntervalFuzzer(const uint8_t *data, size_t size)
|
||||
{
|
||||
uint32_t value = 0;
|
||||
|
||||
int fd = open(MAX_SKIP_INTERVAL, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int ret = read(fd, &value, sizeof(value));
|
||||
if (ret < 0) {
|
||||
printf("%s read fail\n", MAX_SKIP_INTERVAL);
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = write(fd, data, size);
|
||||
if (ret < 0) {
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return true;
|
||||
const char *max_skip_interval = "/dev/memcg/memory.max_skip_interval";
|
||||
bool ret = MemoryFuzzTest(data, size, max_skip_interval);
|
||||
return ret;
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
||||
|
||||
@@ -20,13 +20,18 @@ ohos_fuzztest("NameFuzzTest") {
|
||||
module_out_path = module_output_path
|
||||
fuzz_config_file = "//kernel/linux/build/test/fuzztest/memory/name_fuzzer"
|
||||
|
||||
include_dirs = [ "../include" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
sources = [ "name_fuzzer.cpp" ]
|
||||
sources = [
|
||||
"../src/memorycommon.cpp",
|
||||
"name_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
|
||||
@@ -15,39 +15,14 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
const char *NAME = "/dev/memcg/memory.name";
|
||||
#include "memorycommon.h"
|
||||
|
||||
namespace OHOS {
|
||||
bool NameFuzzer(const uint8_t *data, size_t size)
|
||||
{
|
||||
uint32_t value = 0;
|
||||
|
||||
int fd = open(NAME, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int ret = read(fd, &value, sizeof(value));
|
||||
if (ret < 0) {
|
||||
printf("%s read fail\n", NAME);
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = write(fd, data, size);
|
||||
if (ret < 0) {
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return true;
|
||||
const char *name = "/dev/memcg/memory.name";
|
||||
bool ret = MemoryFuzzTest(data, size, name);
|
||||
return ret;
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
||||
|
||||
+30
-4
@@ -13,9 +13,35 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef TEST_FUZZTEST_GETFTOKENIDCMDCORRECT_FUZZER_H
|
||||
#define TEST_FUZZTEST_GETFTOKENIDCMDCORRECT_FUZZER_H
|
||||
#include <cstddef>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <cstdint>
|
||||
#include "memorycommon.h"
|
||||
|
||||
#define FUZZ_PROJECT_NAME "getftokenidcmdcorrect_fuzzer"
|
||||
namespace OHOS {
|
||||
bool MemoryFuzzTest(const uint8_t *data, size_t size, const char *pathname)
|
||||
{
|
||||
uint32_t value = 0;
|
||||
|
||||
#endif // TEST_FUZZTEST_GETFTOKENIDCMDCORRECT_FUZZER_H
|
||||
int fd = open(pathname, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int ret = read(fd, &value, sizeof(value));
|
||||
if (ret < 0) {
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = write(fd, data, size);
|
||||
if (ret < 0) {
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -21,13 +21,18 @@ ohos_fuzztest("UbUfs2zramRatioFuzzTest") {
|
||||
fuzz_config_file =
|
||||
"//kernel/linux/build/test/fuzztest/memory/ubufs2zramratio_fuzzer"
|
||||
|
||||
include_dirs = [ "../include" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
sources = [ "ubufs2zramratio_fuzzer.cpp" ]
|
||||
sources = [
|
||||
"../src/memorycommon.cpp",
|
||||
"ubufs2zramratio_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
|
||||
@@ -15,39 +15,14 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
const char *UB_UFS2ZRAM_RATIO = "/dev/memcg/memory.ub_ufs2zram_ratio";
|
||||
#include "memorycommon.h"
|
||||
|
||||
namespace OHOS {
|
||||
bool UbUfs2zramRatioFuzzer(const uint8_t *data, size_t size)
|
||||
{
|
||||
uint32_t value = 0;
|
||||
|
||||
int fd = open(UB_UFS2ZRAM_RATIO, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int ret = read(fd, &value, sizeof(value));
|
||||
if (ret < 0) {
|
||||
printf("%s read fail\n", UB_UFS2ZRAM_RATIO);
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = write(fd, data, sizeof(uint8_t));
|
||||
if (ret < 0) {
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return true;
|
||||
const char *ub_ufs2zram_ratio = "/dev/memcg/memory.ub_ufs2zram_ratio";
|
||||
bool ret = MemoryFuzzTest(data, size, ub_ufs2zram_ratio);
|
||||
return ret;
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
||||
|
||||
@@ -21,13 +21,18 @@ ohos_fuzztest("ZramCriticalThresholdFuzzTest") {
|
||||
fuzz_config_file =
|
||||
"//kernel/linux/build/test/fuzztest/memory/zramcriticalthreshold_fuzzer"
|
||||
|
||||
include_dirs = [ "../include" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
sources = [ "zramcriticalthreshold_fuzzer.cpp" ]
|
||||
sources = [
|
||||
"../src/memorycommon.cpp",
|
||||
"zramcriticalthreshold_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
|
||||
@@ -15,39 +15,14 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
const char *ZRAM_CRITICAL_THRESHOLD = "/dev/memcg/memory.zram_critical_threshold";
|
||||
#include "memorycommon.h"
|
||||
|
||||
namespace OHOS {
|
||||
bool ZramCriticalThresholdFuzzer(const uint8_t *data, size_t size)
|
||||
{
|
||||
uint32_t value = 0;
|
||||
|
||||
int fd = open(ZRAM_CRITICAL_THRESHOLD, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int ret = read(fd, &value, sizeof(value));
|
||||
if (ret < 0) {
|
||||
printf("%s read fail\n", ZRAM_CRITICAL_THRESHOLD);
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = write(fd, data, size);
|
||||
if (ret < 0) {
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return true;
|
||||
const char *zram_critical_threshold = "/dev/memcg/memory.zram_critical_threshold";
|
||||
bool ret = MemoryFuzzTest(data, size, zram_critical_threshold);
|
||||
return ret;
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
||||
|
||||
@@ -21,13 +21,18 @@ ohos_fuzztest("ZramWmRatioFuzzTest") {
|
||||
fuzz_config_file =
|
||||
"//kernel/linux/build/test/fuzztest/memory/zramwmratio_fuzzer"
|
||||
|
||||
include_dirs = [ "../include" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
sources = [ "zramwmratio_fuzzer.cpp" ]
|
||||
sources = [
|
||||
"../src/memorycommon.cpp",
|
||||
"zramwmratio_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
|
||||
@@ -15,39 +15,14 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
const char *ZRAM_WR_RATIO = "/dev/memcg/memory.zram_wm_ratio";
|
||||
#include "memorycommon.h"
|
||||
|
||||
namespace OHOS {
|
||||
bool ZramWmRatioFuzzer(const uint8_t *data, size_t size)
|
||||
{
|
||||
uint32_t value = 0;
|
||||
|
||||
int fd = open(ZRAM_WR_RATIO, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int ret = read(fd, &value, sizeof(value));
|
||||
if (ret < 0) {
|
||||
printf("%s read fail\n", ZRAM_WR_RATIO);
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = write(fd, data, sizeof(uint8_t));
|
||||
if (ret < 0) {
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return true;
|
||||
const char *zram_wr_ratio = "/dev/memcg/memory.zram_wm_ratio";
|
||||
bool ret = MemoryFuzzTest(data, size, zram_wr_ratio);
|
||||
return ret;
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
||||
|
||||
@@ -21,13 +21,18 @@ ohos_fuzztest("ZswapdMaxReclaimSizeFuzzTest") {
|
||||
fuzz_config_file =
|
||||
"//kernel/linux/build/test/fuzztest/memory/zswapdmaxreclaimsize_fuzzer"
|
||||
|
||||
include_dirs = [ "../include" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
sources = [ "zswapdmaxreclaimsize_fuzzer.cpp" ]
|
||||
sources = [
|
||||
"../src/memorycommon.cpp",
|
||||
"zswapdmaxreclaimsize_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
|
||||
@@ -15,39 +15,14 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
const char *ZSWAPD_MAX_RECLAIM_SIZE = "/dev/memcg/memory.zswapd_max_reclaim_size";
|
||||
#include "memorycommon.h"
|
||||
|
||||
namespace OHOS {
|
||||
bool ZswapdMaxReclaimSizeFuzzer(const uint8_t *data, size_t size)
|
||||
{
|
||||
uint32_t value = 0;
|
||||
|
||||
int fd = open(ZSWAPD_MAX_RECLAIM_SIZE, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int ret = read(fd, &value, sizeof(value));
|
||||
if (ret < 0) {
|
||||
printf("%s read fail\n", ZSWAPD_MAX_RECLAIM_SIZE);
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = write(fd, data, size);
|
||||
if (ret < 0) {
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return true;
|
||||
const char *zswapd_max_reclaim_size = "/dev/memcg/memory.zswapd_max_reclaim_size";
|
||||
bool ret = MemoryFuzzTest(data, size, zswapd_max_reclaim_size);
|
||||
return ret;
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
||||
|
||||
@@ -21,13 +21,18 @@ ohos_fuzztest("ZswapdMemcgsparamFuzzTest") {
|
||||
fuzz_config_file =
|
||||
"//kernel/linux/build/test/fuzztest/memory/zswapdmemcgsparam_fuzzer"
|
||||
|
||||
include_dirs = [ "../include" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
sources = [ "zswapdmemcgsparam_fuzzer.cpp" ]
|
||||
sources = [
|
||||
"../src/memorycommon.cpp",
|
||||
"zswapdmemcgsparam_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
|
||||
@@ -15,39 +15,14 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
const char *ZSWAPD_MEMCGS_PARAM = "/dev/memcg/memory.zswapd_memcgs_param";
|
||||
#include "memorycommon.h"
|
||||
|
||||
namespace OHOS {
|
||||
bool ZswapdMemcgsParamFuzzer(const uint8_t *data, size_t size)
|
||||
{
|
||||
uint32_t value = 0;
|
||||
|
||||
int fd = open(ZSWAPD_MEMCGS_PARAM, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int ret = read(fd, &value, sizeof(value));
|
||||
if (ret < 0) {
|
||||
printf("%s read fail\n", ZSWAPD_MEMCGS_PARAM);
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = write(fd, data, size);
|
||||
if (ret < 0) {
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return true;
|
||||
const char *zswapd_memcgs_param = "/dev/memcg/memory.zswapd_memcgs_param";
|
||||
bool ret = MemoryFuzzTest(data, size, zswapd_memcgs_param);
|
||||
return ret;
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
||||
|
||||
@@ -21,13 +21,18 @@ ohos_fuzztest("ZswapdPressureShowFuzzTest") {
|
||||
fuzz_config_file =
|
||||
"//kernel/linux/build/test/fuzztest/memory/zswapdpressureshow_fuzzer"
|
||||
|
||||
include_dirs = [ "../include" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
sources = [ "zswapdpressureshow_fuzzer.cpp" ]
|
||||
sources = [
|
||||
"../src/memorycommon.cpp",
|
||||
"zswapdpressureshow_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
|
||||
@@ -15,39 +15,14 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
const char *ZSWAPD_PRESSURE_SHOW = "/dev/memcg/memory.zswapd_pressure_show";
|
||||
#include "memorycommon.h"
|
||||
|
||||
namespace OHOS {
|
||||
bool ZswapdPressureShowFuzzer(const uint8_t *data, size_t size)
|
||||
{
|
||||
uint32_t value = 0;
|
||||
|
||||
int fd = open(ZSWAPD_PRESSURE_SHOW, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int ret = read(fd, &value, sizeof(value));
|
||||
if (ret < 0) {
|
||||
printf("%s read fail\n", ZSWAPD_PRESSURE_SHOW);
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = write(fd, data, sizeof(uint8_t));
|
||||
if (ret < 0) {
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return true;
|
||||
const char *zswapd_pressure_show = "/dev/memcg/memory.zswapd_pressure_show";
|
||||
bool ret = MemoryFuzzTest(data, size, zswapd_pressure_show);
|
||||
return ret;
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
||||
|
||||
@@ -21,13 +21,18 @@ ohos_fuzztest("ZswapdSingleMemcgParamFuzzTest") {
|
||||
fuzz_config_file =
|
||||
"//kernel/linux/build/test/fuzztest/memory/zswapdsinglememcgparam_fuzzer"
|
||||
|
||||
include_dirs = [ "../include" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
sources = [ "zswapdsinglememcgparam_fuzzer.cpp" ]
|
||||
sources = [
|
||||
"../src/memorycommon.cpp",
|
||||
"zswapdsinglememcgparam_fuzzer.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
|
||||
+4
-29
@@ -15,39 +15,14 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
const char *ZSWAPD_SINGLE_MEMCG_PARAM = "/dev/memcg/memory.zswapd_single_memcg_param";
|
||||
#include "memorycommon.h"
|
||||
|
||||
namespace OHOS {
|
||||
bool ZswapdSingleMemcgParamFuzzer(const uint8_t *data, size_t size)
|
||||
{
|
||||
uint32_t value = 0;
|
||||
|
||||
int fd = open(ZSWAPD_SINGLE_MEMCG_PARAM, O_RDWR);
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int ret = read(fd, &value, sizeof(value));
|
||||
if (ret < 0) {
|
||||
printf("%s read fail\n", ZSWAPD_SINGLE_MEMCG_PARAM);
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = write(fd, data, size);
|
||||
if (ret < 0) {
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return true;
|
||||
const char *zswapd_single_memcg_param = "/dev/memcg/memory.zswapd_single_memcg_param";
|
||||
bool ret = MemoryFuzzTest(data, size, zswapd_single_memcg_param);
|
||||
return ret;
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "__config"
|
||||
#include "rtg_interface.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "__config"
|
||||
#include "rtg_interface.h"
|
||||
|
||||
using namespace std;
|
||||
@@ -22,14 +25,14 @@ namespace OHOS {
|
||||
bool BeginFrameFreqFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
bool ret = false;
|
||||
constexpr int MARGIN_UPPER_LIMIT_TIME = 32000;
|
||||
constexpr int MARGIN_LOWER_LIMIT_TIME = -32000;
|
||||
constexpr int margin_upper_limit_time = 32000;
|
||||
constexpr int margin_lower_limit_time = -32000;
|
||||
if (data == nullptr) {
|
||||
return ret;
|
||||
} else {
|
||||
uint8_t *countData = const_cast<uint8_t *>(data);
|
||||
int margin = *(reinterpret_cast<int *>(countData));
|
||||
if (margin < MARGIN_LOWER_LIMIT_TIME || margin > MARGIN_UPPER_LIMIT_TIME) {
|
||||
if (margin < margin_lower_limit_time || margin > margin_upper_limit_time) {
|
||||
return ret;
|
||||
}
|
||||
int grpId = 2;
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "__config"
|
||||
#include "rtg_interface.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "__config"
|
||||
#include "rtg_interface.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "__config"
|
||||
#include "rtg_interface.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "__config"
|
||||
#include "rtg_interface.h"
|
||||
|
||||
using namespace std;
|
||||
@@ -22,14 +25,14 @@ namespace OHOS {
|
||||
bool SetMarginFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
bool ret = false;
|
||||
constexpr int MARGIN_UPPER_LIMIT_TIME = 32000;
|
||||
constexpr int MARGIN_LOWER_LIMIT_TIME = -32000;
|
||||
constexpr int margin_upper_limit_time = 32000;
|
||||
constexpr int margin_lower_limit_time = -32000;
|
||||
if (data == nullptr) {
|
||||
return ret;
|
||||
} else {
|
||||
uint8_t *countData = const_cast<uint8_t *>(data);
|
||||
int margin = *(reinterpret_cast<int *>(countData));
|
||||
if (margin < MARGIN_LOWER_LIMIT_TIME || margin > MARGIN_UPPER_LIMIT_TIME) {
|
||||
if (margin < margin_lower_limit_time || margin > margin_upper_limit_time) {
|
||||
return ret;
|
||||
}
|
||||
int grpId = 2;
|
||||
|
||||
Reference in New Issue
Block a user