1 /*
2 * Copyright (c) 2023 Shenzhen Kaihong DID Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "imagegetcapability_fuzzer.h"
17 #include <hdf_log.h>
18 #include <vector>
19 #include "v2_0/icodec_image.h"
20 using namespace OHOS::HDI::Codec::Image::V2_0;
21 using namespace OHOS;
22 using namespace std;
23
dlclose(void * handle)24 extern "C" __attribute__((visibility("default"))) int dlclose(void* handle)
25 {
26 return 0;
27 }
28
29 namespace OHOS {
30 namespace Codec {
31 namespace Image {
GetCapabilityList(const uint8_t * data,size_t size)32 bool GetCapabilityList(const uint8_t *data, size_t size)
33 {
34 if (data == nullptr) {
35 return false;
36 }
37
38 sptr<ICodecImage> image = ICodecImage::Get(false);
39 if (image == nullptr) {
40 HDF_LOGE("%{public}s: get ICodecImage failed\n", __func__);
41 return false;
42 }
43
44 vector<CodecImageCapability> caps;
45 auto err = image->GetImageCapability(caps);
46 if (err != HDF_SUCCESS) {
47 HDF_LOGE("%{public}s GetImageCapability return %{public}d", __func__, err);
48 }
49 return true;
50 }
51 } // namespace Image
52 } // namespace Codec
53 } // namespace OHOS
54
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)55 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
56 {
57 OHOS::Codec::Image::GetCapabilityList(data, size);
58 return 0;
59 }
60