mirror of
https://gitee.com/openharmony/account_os_account
synced 2024-11-23 02:00:01 +00:00
修复fuzz用例
Signed-off-by: cc_ggboy <chenweimin8@huawei.com>
This commit is contained in:
parent
f53583dc76
commit
5c45258f03
@ -26,15 +26,25 @@
|
||||
using namespace std;
|
||||
using namespace OHOS::AccountSA;
|
||||
const int LOCAL_ID = 100;
|
||||
const uint8_t ARRAY_CHAR_SIZE = 62;
|
||||
const char CHAR_ARRAY[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
|
||||
static void GenerateRandStr(uint32_t len, const uint8_t *data, std::string& res)
|
||||
{
|
||||
for (uint32_t i = 0; i < len; i++) {
|
||||
uint32_t index = data[i] % ARRAY_CHAR_SIZE;
|
||||
res.push_back(CHAR_ARRAY[index]);
|
||||
}
|
||||
}
|
||||
|
||||
namespace OHOS {
|
||||
bool SetOsAccountProfilePhotoFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
bool result = false;
|
||||
if ((data != nullptr) && (size != 0)) {
|
||||
FuzzData fuzzData(data, size);
|
||||
std::string testPhotoStr(fuzzData.GenerateRandomString());
|
||||
result = OsAccountManager::SetOsAccountProfilePhoto(LOCAL_ID, testPhotoStr);
|
||||
std::string photo;
|
||||
GenerateRandStr(size, data, photo);
|
||||
result = OsAccountManager::SetOsAccountProfilePhoto(LOCAL_ID, photo);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user