1fb299fa2Sopenharmony_ci/*
2fb299fa2Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
3fb299fa2Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4fb299fa2Sopenharmony_ci * you may not use this file except in compliance with the License.
5fb299fa2Sopenharmony_ci * You may obtain a copy of the License at
6fb299fa2Sopenharmony_ci *
7fb299fa2Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8fb299fa2Sopenharmony_ci *
9fb299fa2Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10fb299fa2Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11fb299fa2Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12fb299fa2Sopenharmony_ci * See the License for the specific language governing permissions and
13fb299fa2Sopenharmony_ci * limitations under the License.
14fb299fa2Sopenharmony_ci */
15fb299fa2Sopenharmony_ci
16fb299fa2Sopenharmony_ci#include "package_fuzzer.h"
17fb299fa2Sopenharmony_ci
18fb299fa2Sopenharmony_ci#include <array>
19fb299fa2Sopenharmony_ci#include <cstddef>
20fb299fa2Sopenharmony_ci#include <cstdint>
21fb299fa2Sopenharmony_ci#include <cstring>
22fb299fa2Sopenharmony_ci#include <fcntl.h>
23fb299fa2Sopenharmony_ci#include <iostream>
24fb299fa2Sopenharmony_ci#include <string>
25fb299fa2Sopenharmony_ci#include <sys/mman.h>
26fb299fa2Sopenharmony_ci#include <sys/stat.h>
27fb299fa2Sopenharmony_ci#include <unistd.h>
28fb299fa2Sopenharmony_ci#include <vector>
29fb299fa2Sopenharmony_ci#include "log/log.h"
30fb299fa2Sopenharmony_ci#include "package.h"
31fb299fa2Sopenharmony_ci#include "pkg_algorithm.h"
32fb299fa2Sopenharmony_ci#include "pkg_manager.h"
33fb299fa2Sopenharmony_ci#include "pkg_manager_impl.h"
34fb299fa2Sopenharmony_ci#include "pkg_fuzz_test.h"
35fb299fa2Sopenharmony_ci#include "pkg_utils.h"
36fb299fa2Sopenharmony_ci
37fb299fa2Sopenharmony_ciusing namespace Updater;
38fb299fa2Sopenharmony_ciusing namespace Hpackage;
39fb299fa2Sopenharmony_cinamespace OHOS {
40fb299fa2Sopenharmony_ciclass FuzzPackageUnitTest : public FuzzPkgTest {
41fb299fa2Sopenharmony_cipublic:
42fb299fa2Sopenharmony_ci    FuzzPackageUnitTest() {}
43fb299fa2Sopenharmony_ci    ~FuzzPackageUnitTest() override {}
44fb299fa2Sopenharmony_cipublic:
45fb299fa2Sopenharmony_ci    int TestInvalidCreatePackage()
46fb299fa2Sopenharmony_ci    {
47fb299fa2Sopenharmony_ci        std::vector<ComponentInfoExt> info;
48fb299fa2Sopenharmony_ci        uint8_t pkgType = PkgPackType::PKG_PACK_TYPE_UPGRADE;
49fb299fa2Sopenharmony_ci        int ret = CreatePackage(nullptr, info, nullptr, GetFuzzPrivateKeyName(0).c_str());
50fb299fa2Sopenharmony_ci
51fb299fa2Sopenharmony_ci        UpgradePkgInfoExt pkgInfoExt {};
52fb299fa2Sopenharmony_ci        pkgInfoExt.pkgType = pkgType;
53fb299fa2Sopenharmony_ci        ret = CreatePackage(&pkgInfoExt, info, nullptr, GetFuzzPrivateKeyName(0).c_str());
54fb299fa2Sopenharmony_ci
55fb299fa2Sopenharmony_ci        constexpr uint32_t digestLen = 32;
56fb299fa2Sopenharmony_ci        ret = VerifyPackage(nullptr, GetFuzzCertName(0).c_str(), nullptr, nullptr, digestLen);
57fb299fa2Sopenharmony_ci
58fb299fa2Sopenharmony_ci        std::string packagePath = TEST_PATH_TO + testPackageName;
59fb299fa2Sopenharmony_ci        pkgInfoExt.pkgType = pkgType;
60fb299fa2Sopenharmony_ci        ret = CreatePackage(&pkgInfoExt, info, packagePath.c_str(), GetFuzzPrivateKeyName(0).c_str());
61fb299fa2Sopenharmony_ci
62fb299fa2Sopenharmony_ci        pkgType = PkgPackType::PKG_PACK_TYPE_ZIP;
63fb299fa2Sopenharmony_ci        pkgInfoExt.pkgType = pkgType;
64fb299fa2Sopenharmony_ci        ret = CreatePackage(&pkgInfoExt, info, packagePath.c_str(), GetFuzzPrivateKeyName(0).c_str());
65fb299fa2Sopenharmony_ci
66fb299fa2Sopenharmony_ci        pkgType = PkgPackType::PKG_PACK_TYPE_LZ4;
67fb299fa2Sopenharmony_ci        pkgInfoExt.pkgType = pkgType;
68fb299fa2Sopenharmony_ci        ret = CreatePackage(&pkgInfoExt, info, packagePath.c_str(), GetFuzzPrivateKeyName(0).c_str());
69fb299fa2Sopenharmony_ci
70fb299fa2Sopenharmony_ci        pkgType = PkgPackType::PKG_PACK_TYPE_GZIP;
71fb299fa2Sopenharmony_ci        pkgInfoExt.pkgType = pkgType;
72fb299fa2Sopenharmony_ci        ret = CreatePackage(&pkgInfoExt, info, packagePath.c_str(), GetFuzzPrivateKeyName(0).c_str());
73fb299fa2Sopenharmony_ci
74fb299fa2Sopenharmony_ci        pkgType = PkgPackType::PKG_PACK_TYPE_NONE;
75fb299fa2Sopenharmony_ci        pkgInfoExt.pkgType = pkgType;
76fb299fa2Sopenharmony_ci        ret = CreatePackage(&pkgInfoExt, info, packagePath.c_str(), GetFuzzPrivateKeyName(0).c_str());
77fb299fa2Sopenharmony_ci        return ret;
78fb299fa2Sopenharmony_ci    }
79fb299fa2Sopenharmony_ci
80fb299fa2Sopenharmony_ci    int TestPackagePack(int type = PKG_DIGEST_TYPE_SHA256)
81fb299fa2Sopenharmony_ci    {
82fb299fa2Sopenharmony_ci        int32_t ret;
83fb299fa2Sopenharmony_ci        uint32_t updateFileVersion = 1000;
84fb299fa2Sopenharmony_ci        UpgradePkgInfoExt pkgInfo;
85fb299fa2Sopenharmony_ci        pkgInfo.productUpdateId = strdup("555.555.100.555");
86fb299fa2Sopenharmony_ci        pkgInfo.softwareVersion = strdup("100.100.100.100");
87fb299fa2Sopenharmony_ci        pkgInfo.date = strdup("2021-02-02");
88fb299fa2Sopenharmony_ci        pkgInfo.time = strdup("21:23:49");
89fb299fa2Sopenharmony_ci        pkgInfo.entryCount = testFileNames_.size();
90fb299fa2Sopenharmony_ci        pkgInfo.updateFileVersion = updateFileVersion;
91fb299fa2Sopenharmony_ci        pkgInfo.digestMethod = type;
92fb299fa2Sopenharmony_ci        pkgInfo.signMethod = PKG_SIGN_METHOD_RSA;
93fb299fa2Sopenharmony_ci        pkgInfo.pkgType = PKG_PACK_TYPE_UPGRADE;
94fb299fa2Sopenharmony_ci        std::string filePath;
95fb299fa2Sopenharmony_ci        uint32_t componentIdBase = 100;
96fb299fa2Sopenharmony_ci        uint8_t componentFlags = 22;
97fb299fa2Sopenharmony_ci        std::vector<ComponentInfoExt> comp(testFileNames_.size());
98fb299fa2Sopenharmony_ci        for (size_t n = 0; n < testFileNames_.size(); n++) {
99fb299fa2Sopenharmony_ci            comp[n].componentAddr = strdup(testFileNames_[n].c_str());
100fb299fa2Sopenharmony_ci            filePath = TEST_PATH_FROM;
101fb299fa2Sopenharmony_ci            filePath += testFileNames_[n].c_str();
102fb299fa2Sopenharmony_ci            comp[n].filePath = strdup(filePath.c_str());
103fb299fa2Sopenharmony_ci            comp[n].version = strdup("55555555");
104fb299fa2Sopenharmony_ci            ret = BuildFileDigest(*comp[n].digest, sizeof(comp[n].digest), filePath);
105fb299fa2Sopenharmony_ci            comp[n].size = GetFileSize(filePath);
106fb299fa2Sopenharmony_ci            comp[n].originalSize = comp[n].size;
107fb299fa2Sopenharmony_ci            comp[n].id = n + componentIdBase;
108fb299fa2Sopenharmony_ci            comp[n].resType = 1;
109fb299fa2Sopenharmony_ci            comp[n].type = 1;
110fb299fa2Sopenharmony_ci            comp[n].flags = componentFlags;
111fb299fa2Sopenharmony_ci            filePath.clear();
112fb299fa2Sopenharmony_ci        }
113fb299fa2Sopenharmony_ci        std::string packagePath = TEST_PATH_TO;
114fb299fa2Sopenharmony_ci        packagePath += testPackageName;
115fb299fa2Sopenharmony_ci        ret = CreatePackage(&pkgInfo, comp, packagePath.c_str(),
116fb299fa2Sopenharmony_ci            GetFuzzPrivateKeyName(pkgInfo.digestMethod).c_str());
117fb299fa2Sopenharmony_ci        for (size_t n = 0; n < testFileNames_.size(); n++) {
118fb299fa2Sopenharmony_ci            free(comp[n].componentAddr);
119fb299fa2Sopenharmony_ci            free(comp[n].filePath);
120fb299fa2Sopenharmony_ci            free(comp[n].version);
121fb299fa2Sopenharmony_ci        }
122fb299fa2Sopenharmony_ci        free(pkgInfo.productUpdateId);
123fb299fa2Sopenharmony_ci        free(pkgInfo.softwareVersion);
124fb299fa2Sopenharmony_ci        free(pkgInfo.date);
125fb299fa2Sopenharmony_ci        free(pkgInfo.time);
126fb299fa2Sopenharmony_ci        return ret;
127fb299fa2Sopenharmony_ci    }
128fb299fa2Sopenharmony_ci
129fb299fa2Sopenharmony_ci    int TestZipPkgCompress(int digestMethod)
130fb299fa2Sopenharmony_ci    {
131fb299fa2Sopenharmony_ci        return CreateZipPackage(testFileNames_, TEST_PATH_TO + testZipPackageName, TEST_PATH_FROM, digestMethod);
132fb299fa2Sopenharmony_ci    }
133fb299fa2Sopenharmony_ci
134fb299fa2Sopenharmony_ci    int TestPackageUnpack(int type)
135fb299fa2Sopenharmony_ci    {
136fb299fa2Sopenharmony_ci        std::vector<std::string> componentsList;
137fb299fa2Sopenharmony_ci        // 使用上面打包的包进行解析
138fb299fa2Sopenharmony_ci        int32_t ret = pkgManager_->LoadPackage(
139fb299fa2Sopenharmony_ci            testPackagePath + "test_package.zip", GetFuzzCertName(type), componentsList);
140fb299fa2Sopenharmony_ci
141fb299fa2Sopenharmony_ci        for (size_t n = 0; n < componentsList.size(); n++) {
142fb299fa2Sopenharmony_ci            PKG_LOGI("comp [%zu] file name: %s \r\n", n, (TEST_PATH_TO + componentsList[n]).c_str());
143fb299fa2Sopenharmony_ci            ExtractFile(pkgManager_, componentsList, n);
144fb299fa2Sopenharmony_ci        }
145fb299fa2Sopenharmony_ci        return ret;
146fb299fa2Sopenharmony_ci    }
147fb299fa2Sopenharmony_ci
148fb299fa2Sopenharmony_ci    int TestZipPkgDecompress(int digestMethod)
149fb299fa2Sopenharmony_ci    {
150fb299fa2Sopenharmony_ci        std::vector<std::string> componentsList;
151fb299fa2Sopenharmony_ci        int32_t ret = pkgManager_->LoadPackage(TEST_PATH_TO + testZipPackageName,
152fb299fa2Sopenharmony_ci            GetFuzzCertName(digestMethod), componentsList);
153fb299fa2Sopenharmony_ci
154fb299fa2Sopenharmony_ci        for (size_t n = 0; n < componentsList.size(); n++) {
155fb299fa2Sopenharmony_ci            PKG_LOGI("file name: %s \r\n", (TEST_PATH_TO + componentsList[n]).c_str());
156fb299fa2Sopenharmony_ci            ExtractFile(pkgManager_, componentsList, n);
157fb299fa2Sopenharmony_ci        }
158fb299fa2Sopenharmony_ci        return ret;
159fb299fa2Sopenharmony_ci    }
160fb299fa2Sopenharmony_ci
161fb299fa2Sopenharmony_ci    int TestGZipPkgCompress()
162fb299fa2Sopenharmony_ci    {
163fb299fa2Sopenharmony_ci        int ret = TestPackagePack();
164fb299fa2Sopenharmony_ci        std::vector<std::pair<std::string, ZipFileInfo>> files;
165fb299fa2Sopenharmony_ci        ZipFileInfo zipFile;
166fb299fa2Sopenharmony_ci        zipFile.fileInfo.identity = testPackageName;
167fb299fa2Sopenharmony_ci        zipFile.fileInfo.packMethod = PKG_COMPRESS_METHOD_GZIP;
168fb299fa2Sopenharmony_ci        zipFile.fileInfo.digestMethod = PKG_DIGEST_TYPE_CRC;
169fb299fa2Sopenharmony_ci        std::string fileName = TEST_PATH_TO + testPackageName;
170fb299fa2Sopenharmony_ci        files.push_back(std::pair<std::string, ZipFileInfo>(fileName, zipFile));
171fb299fa2Sopenharmony_ci
172fb299fa2Sopenharmony_ci        PkgInfo info;
173fb299fa2Sopenharmony_ci        info.signMethod = PKG_SIGN_METHOD_RSA;
174fb299fa2Sopenharmony_ci        info.digestMethod  = PKG_DIGEST_TYPE_SHA256;
175fb299fa2Sopenharmony_ci        info.pkgType = PKG_PACK_TYPE_GZIP;
176fb299fa2Sopenharmony_ci        ret = pkgManager_->CreatePackage(TEST_PATH_TO + testGZipPackageName,
177fb299fa2Sopenharmony_ci            GetFuzzPrivateKeyName(info.digestMethod), &info, files);
178fb299fa2Sopenharmony_ci        return ret;
179fb299fa2Sopenharmony_ci    }
180fb299fa2Sopenharmony_ci
181fb299fa2Sopenharmony_ci    int TestVerifyUpgradePackage()
182fb299fa2Sopenharmony_ci    {
183fb299fa2Sopenharmony_ci        constexpr size_t digestSize = 32;
184fb299fa2Sopenharmony_ci        std::vector<uint8_t> digest(digestSize);
185fb299fa2Sopenharmony_ci        std::string path = testPackagePath + "test_package.zip";
186fb299fa2Sopenharmony_ci        BuildFileDigest(*digest.data(), digest.capacity(), path.c_str());
187fb299fa2Sopenharmony_ci        int ret = VerifyPackage(path.c_str(), GetFuzzCertName(0).c_str(), "", digest.data(), digest.capacity());
188fb299fa2Sopenharmony_ci        ret = VerifyPackage(nullptr, nullptr, nullptr, nullptr, digest.capacity());
189fb299fa2Sopenharmony_ci        return ret;
190fb299fa2Sopenharmony_ci    }
191fb299fa2Sopenharmony_ci
192fb299fa2Sopenharmony_ci    int TestVerifyPackageWithCallback()
193fb299fa2Sopenharmony_ci    {
194fb299fa2Sopenharmony_ci        std::string path = testPackagePath + "test_package.zip";
195fb299fa2Sopenharmony_ci        int ret = VerifyPackageWithCallback(path.c_str(), GetFuzzCertName(0).c_str(),
196fb299fa2Sopenharmony_ci            [](int32_t result, uint32_t percent) { PKG_LOGI("progress: %u\n", percent); });
197fb299fa2Sopenharmony_ci
198fb299fa2Sopenharmony_ci        std::string keyPath = "";
199fb299fa2Sopenharmony_ci        ret = VerifyPackageWithCallback(path.c_str(), keyPath.c_str(),
200fb299fa2Sopenharmony_ci            [](int32_t result, uint32_t percent) { PKG_LOGI("progress: %u\n", percent); });
201fb299fa2Sopenharmony_ci
202fb299fa2Sopenharmony_ci        std::function<void(int32_t result, uint32_t percent)> cb = nullptr;
203fb299fa2Sopenharmony_ci        ret = VerifyPackageWithCallback(path.c_str(), GetFuzzCertName(0).c_str(), cb);
204fb299fa2Sopenharmony_ci
205fb299fa2Sopenharmony_ci        path = "";
206fb299fa2Sopenharmony_ci        ret = VerifyPackageWithCallback(path.c_str(), GetFuzzCertName(0).c_str(),
207fb299fa2Sopenharmony_ci            [](int32_t result, uint32_t percent) { PKG_LOGI("progress: %u\n", percent); });
208fb299fa2Sopenharmony_ci        return ret;
209fb299fa2Sopenharmony_ci    }
210fb299fa2Sopenharmony_ci
211fb299fa2Sopenharmony_ci    int TestLz4PkgCompress()
212fb299fa2Sopenharmony_ci    {
213fb299fa2Sopenharmony_ci        int ret = TestPackagePack();
214fb299fa2Sopenharmony_ci        std::vector<std::pair<std::string, Lz4FileInfo>> files;
215fb299fa2Sopenharmony_ci        Lz4FileInfo zipFile;
216fb299fa2Sopenharmony_ci        int8_t compressionLevel = 14;
217fb299fa2Sopenharmony_ci        zipFile.fileInfo.identity = testPackageName;
218fb299fa2Sopenharmony_ci        zipFile.fileInfo.packMethod = PKG_COMPRESS_METHOD_LZ4;
219fb299fa2Sopenharmony_ci        zipFile.fileInfo.digestMethod = PKG_DIGEST_TYPE_CRC;
220fb299fa2Sopenharmony_ci        zipFile.compressionLevel = compressionLevel;
221fb299fa2Sopenharmony_ci        zipFile.blockSizeID = 0;
222fb299fa2Sopenharmony_ci        zipFile.contentChecksumFlag = 0;
223fb299fa2Sopenharmony_ci        zipFile.blockIndependence = 0;
224fb299fa2Sopenharmony_ci        std::string fileName = TEST_PATH_TO + testPackageName;
225fb299fa2Sopenharmony_ci        files.push_back(std::pair<std::string, Lz4FileInfo>(fileName, zipFile));
226fb299fa2Sopenharmony_ci
227fb299fa2Sopenharmony_ci        PkgInfo info;
228fb299fa2Sopenharmony_ci        info.pkgType = PKG_PACK_TYPE_LZ4;
229fb299fa2Sopenharmony_ci        info.signMethod = PKG_SIGN_METHOD_RSA;
230fb299fa2Sopenharmony_ci        info.digestMethod  = PKG_DIGEST_TYPE_SHA256;
231fb299fa2Sopenharmony_ci        ret = pkgManager_->CreatePackage(TEST_PATH_TO + testLz4PackageName,
232fb299fa2Sopenharmony_ci            GetFuzzPrivateKeyName(info.digestMethod), &info, files);
233fb299fa2Sopenharmony_ci        return ret;
234fb299fa2Sopenharmony_ci    }
235fb299fa2Sopenharmony_ci};
236fb299fa2Sopenharmony_ci
237fb299fa2Sopenharmony_civoid FUZZPackageUnitTest(const uint8_t* data, size_t size)
238fb299fa2Sopenharmony_ci{
239fb299fa2Sopenharmony_ci    FuzzPackageUnitTest test;
240fb299fa2Sopenharmony_ci    (void)test.TestLz4PkgCompress();
241fb299fa2Sopenharmony_ci    (void)test.TestInvalidCreatePackage();
242fb299fa2Sopenharmony_ci    (void)test.TestVerifyUpgradePackage();
243fb299fa2Sopenharmony_ci    (void)test.TestVerifyPackageWithCallback();
244fb299fa2Sopenharmony_ci    (void)test.TestPackagePack(PKG_DIGEST_TYPE_SHA256);
245fb299fa2Sopenharmony_ci    (void)test.TestPackageUnpack(PKG_DIGEST_TYPE_SHA256);
246fb299fa2Sopenharmony_ci    (void)test.TestZipPkgCompress(PKG_DIGEST_TYPE_SHA256);
247fb299fa2Sopenharmony_ci    (void)test.TestZipPkgDecompress(PKG_DIGEST_TYPE_SHA256);
248fb299fa2Sopenharmony_ci    (void)test.TestGZipPkgCompress();
249fb299fa2Sopenharmony_ci}
250fb299fa2Sopenharmony_ci
251fb299fa2Sopenharmony_civoid FuzzVerifyPackage(const uint8_t* data, size_t size)
252fb299fa2Sopenharmony_ci{
253fb299fa2Sopenharmony_ci    constexpr size_t digestSize = 32;
254fb299fa2Sopenharmony_ci    std::vector<uint8_t> digest(digestSize);
255fb299fa2Sopenharmony_ci    const std::string keyPath = "/data/fuzz/test/signing_cert.crt";
256fb299fa2Sopenharmony_ci    const std::string pkgPath = "/data/fuzz/test/updater.zip";
257fb299fa2Sopenharmony_ci    const std::string pkgDir = "/data/fuzz/test";
258fb299fa2Sopenharmony_ci    const std::string dataInfo = std::string(reinterpret_cast<const char*>(data), size);
259fb299fa2Sopenharmony_ci    VerifyPackage(dataInfo.c_str(), keyPath.c_str(), "", digest.data(), digest.capacity());
260fb299fa2Sopenharmony_ci    VerifyPackage(pkgPath.c_str(), dataInfo.c_str(), "", digest.data(), digest.capacity());
261fb299fa2Sopenharmony_ci    VerifyPackage(pkgPath.c_str(), keyPath.c_str(), dataInfo.c_str(), digest.data(), digest.capacity());
262fb299fa2Sopenharmony_ci    VerifyPackage(pkgPath.c_str(), keyPath.c_str(), "", data, size);
263fb299fa2Sopenharmony_ci
264fb299fa2Sopenharmony_ci    VerifyPackageWithCallback(dataInfo.c_str(), keyPath.c_str(),
265fb299fa2Sopenharmony_ci        [](int32_t result, uint32_t percent) {});
266fb299fa2Sopenharmony_ci    VerifyPackageWithCallback(pkgPath, dataInfo.c_str(), [](int32_t result, uint32_t percent) {});
267fb299fa2Sopenharmony_ci
268fb299fa2Sopenharmony_ci    ExtraPackageDir(dataInfo.c_str(), keyPath.c_str(), nullptr, pkgDir.c_str());
269fb299fa2Sopenharmony_ci    ExtraPackageDir(pkgPath.c_str(), dataInfo.c_str(), nullptr, pkgDir.c_str());
270fb299fa2Sopenharmony_ci    ExtraPackageDir(pkgPath.c_str(), keyPath.c_str(), dataInfo.c_str(), pkgDir.c_str());
271fb299fa2Sopenharmony_ci    ExtraPackageDir(pkgPath.c_str(), keyPath.c_str(), nullptr, dataInfo.c_str());
272fb299fa2Sopenharmony_ci
273fb299fa2Sopenharmony_ci    const std::string file = "updater.bin";
274fb299fa2Sopenharmony_ci    ExtraPackageFile(dataInfo.c_str(), keyPath.c_str(), file.c_str(), pkgDir.c_str());
275fb299fa2Sopenharmony_ci    ExtraPackageFile(pkgPath.c_str(), dataInfo.c_str(), file.c_str(), pkgDir.c_str());
276fb299fa2Sopenharmony_ci    ExtraPackageFile(pkgPath.c_str(), keyPath.c_str(), dataInfo.c_str(), pkgDir.c_str());
277fb299fa2Sopenharmony_ci    ExtraPackageFile(pkgPath.c_str(), keyPath.c_str(), file.c_str(), dataInfo.c_str());
278fb299fa2Sopenharmony_ci}
279fb299fa2Sopenharmony_ci}
280fb299fa2Sopenharmony_ci
281fb299fa2Sopenharmony_ci/* Fuzzer entry point */
282fb299fa2Sopenharmony_ciextern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
283fb299fa2Sopenharmony_ci{
284fb299fa2Sopenharmony_ci    /* Run your code on data */
285fb299fa2Sopenharmony_ci    OHOS::FuzzVerifyPackage(data, size);
286fb299fa2Sopenharmony_ci    return 0;
287fb299fa2Sopenharmony_ci}
288fb299fa2Sopenharmony_ci
289