usermanageraddfuzztest1

Signed-off-by: lixiang <lixiang493@huawei.com>
This commit is contained in:
lixiang 2024-03-27 18:17:36 +08:00
parent b2125ac445
commit c0879ea54c

View File

@ -25,7 +25,6 @@
#include "securec.h" #include "securec.h"
#include "user_manager.h" #include "user_manager.h"
using namespace OHOS::StorageDaemon; using namespace OHOS::StorageDaemon;
namespace OHOS { namespace OHOS {
@ -62,17 +61,21 @@ bool StorageDaemonFuzzTest(std::unique_ptr<char[]> data, size_t size)
return true; return true;
} }
bool UserManagerFuzzTest(const uint8_t *data, size_t size) bool UserManagerFuzzTest(const uint8_t *data, size_t size)
{ {
if ((data == nullptr) || (size < sizeof(int32_t))) { if ((data == nullptr) || (size < sizeof(int32_t))) {
return false; return false;
} }
int32_t userId = *(reinterpret_cast<const int32_t *>(data)); int32_t userId = *(reinterpret_cast<const int32_t *>(data));
uint32_t flag = *(reinterpret_cast<const uint32_t *>(data)); uint32_t flag = *(reinterpret_cast<const uint32_t *>(data));
userManager->DestroyUserDirs(userId, flag); userManager->PrepareUserDirs(userId, flag);
userManager->DestroyUserDirs(userId, flag);
userManager->StartUser(userId);
userManager->StopUser(userId);
userManager->CreateBundleDataDir(flag);
return true; return true;
} }
} // namespace OHOS } // namespace OHOS